Configure multiple host in apache with ssl on different port - apache

Hi i want to run multiple sites on same server with ssl on different ports, here is what i did so far.
default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin admin#admin.com
ServerName app.example.com
DocumentRoot path_to_project_directory
<Directory path_to_project_directory>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>
</IfModule>
With above configuration when i run https://aap.example.com on browser it works fine now i want to run same domain on different port with ssl like https://app.example.com:8000, so for this i have made another virtual host file like this.
app.example.com.conf
<VirtualHost *:8000>
ServerAdmin admin#admin.org
ServerName app.example.com
Alias /static/ path_to_project_directory
WSGIPassAuthorization On
WSGIScriptAlias / path_to_project_directory/wsgi.py
WSGIDaemonProcess example_wsgi33 processes=3 threads=15 display-name=example_wsgi33 python-path=path_to_project_directory:path_to_project_directory/venv/lib/python3.9/site-packages
<Directory path_to_project_directory>
WSGIProcessGroup example_wsgi33
WSGIApplicationGroup %{GLOBAL}
DirectoryIndex manage.py
Require all granted
Options -Indexes -MultiViews +SymLinksIfOwnerMatch
Allow from all
</Directory>
<Directory path_to_project_directory>
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
but when i try to run https://app.example.com:8000 it shows me nothing and i'm getting error like took too long to respond..
Anybody has idea how i can run site on different ports.
Here is my ports.conf
Listen 80
Listen 8000
Listen 8001
Listen 8002
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
I have already enabled these ports on my digital ocean firewall

Related

Apache is not working after SSlcert configuration on alternate port

My Working url is given below which was working fine before ssl configuration. but after ssl cert configuration it is not working it is returnnig me the error
which is given below.
Url :
http://my-test-dev02.org.net:81
Error :
This page isn’t working my-test-dev02.org.net redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
Apache configuration which i have is given below :
In 000-default.conf File :
<VirtualHost *:81>
Redirect permanent / https://my-test-dev02.org.net:81
WSGIDaemonProcess skg-sa-ver12.org.net python-path=/volume/python3.8/site-packages
WSGIScriptAlias / /c/my_dashboard/my_dashboard/wsgi.py
<Directory "/c/my_dashboard/my_dashboard">
Require all granted
</Directory>
ServerAdmin webmaster#localhost
DocumentRoot /c/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
default-ssl.conf File
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
#<VirtualHost *:443>
WSGIScriptAlias / /c/my_dashboard/my_dashboard/wsgi.py
ServerAdmin nehak#org.net
<Directory "/c/my_dashboard/my_dashboard">
Require all granted
</Directory>
Alias /media/ /c/my_dashboard/my_dashboard/media/
<Directory /c/my_dashboard/my_dashboard/media>
Require all granted
</Directory>
DocumentRoot /c/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/certs/my-test-dev02_org_net/my-test-dev02_org_net.cer
SSLCertificateKeyFile /etc/apache2/certs/my-test-dev02_org_net.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
In ports.conf file configuration i have :
Listen 81
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
above is my configuration for ssl cert and apache. I don't know why i am getting the error but without ssl cert i was able to access it. but after i am getting the error can anyone help me related this? what i am missing here and why this url is not securely redirecting ?

cannot letsencrypt because port 80 auto redirects to 443

I have a few sites running on a server running apache2 and I have forgotten how I auto forwarded all traffic to https. Trying to run letsencrypt but it must visit the http page first. when I wget the page I receive:
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://example.org/ [following]
I do not see anything in apache2.conf
mysite.conf
<VirtualHost *:80>
ServerAdmin admin
DocumentRoot /var/www/html/mysite/
ServerName example.org
Alias /mysite "/var/www/html/mysite/"
<Directory /var/www/html/mysite/>
Options +FollowSymlinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/mysite
SetEnv HTTP_HOME /var/www/html/mysite
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
mysite-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin
DocumentRoot /var/www/html/mysite/
ServerName mysite.org
ServerAlias www.example.org
Alias / "/var/www/html/mysite/"
<Directory /var/www/html/mysite/>
Options +FollowSymlinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/mysite
SetEnv HTTP_HOME /var/www/html/mysite
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/oldsite/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/oldsite/privkey.pem
</VirtualHost>
</IfModule>
<VirtualHost *:80>
ServerAdmin admin
DocumentRoot /var/www/html/mysite/
ServerName example.org
ServerAlias www.example.org
Alias / "/var/www/html/mysite/"
<Directory /var/www/html/mysite/>
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/mysite
SetEnv HTTP_HOME /var/www/html/mysite
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
not sure what I need to do to allow lets encrypt to complete the certs. Any help would be greatly appreciated!

Disable SSL on specific subdomain

I have a domain say example.com using SSL. Now i have created a test site for the application and hosted in test.example.com. But whenever i am trying to access test.example.com i am getting connection not private error. That sub domain is also using the SSL somehow.
I tried to add redirect rule to http version in .htaccess and vhost files, but not working. Any solution?
Here is the default-ssl.conf file:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/frontend
DirectoryIndex index.html
<Directory /var/www/html/frontend>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine On
SSLCertificateFile /etc/ssl/certfile.crt
SSLCertificateKeyFile /etc/ssl/certkey.key
SSLCertificateChainFile /etc/ssl/gd_bundle-g2-g1.crt
</VirtualHost>
</IfModule>

Can't acces website when ssl enabled

We're trying to use SSL on our website.
The website is on a ubuntu server 2016. I've generated certicates from let's encrypt and followed the ubuntu tutorial but at the end i'm getting ERR_CONNECTION_REFUSED
<VirtualHost *:443>
ServerAdmin webmaster#sitename.eu
ServerName dp7.sitename.eu
ServerAlias www.dp7.sitename.eu
#SSLEngine on
#SSLCertificateFile /etc/letsencrypt/live/sitename.fr/cert.pem
#SSLCertificateChainFile /etc/letsencrypt/live/sitename.fr/fullchain.pem
#SSLCertificateKeyFile /etc/letsencrypt/live/sitename.fr/privkey.pem
DocumentRoot /var/www/bt750
<Directory "/var/www/bt750">
Options +FollowSymLinks -MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog /var/log/apache2/dp7_ssl_error.log
LogLevel warn
CustomLog /var/log/apache2/dp7_ssl_access.log "combined"
</VirtualHost>
i have flushed all my chrome cache, without success
how can i solve this problem ?
You have some errors in apache configuration. You need Listen the 443 port and uncomment SLL configuration
Listen 443
<VirtualHost *:443>
ServerAdmin webmaster#sitename.eu
ServerName dp7.sitename.eu
ServerAlias www.dp7.sitename.eu
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/sitename.fr/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/sitename.fr/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sitename.fr/privkey.pem
DocumentRoot /var/www/bt750
<Directory "/var/www/bt750">
Options +FollowSymLinks -MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog /var/log/apache2/dp7_ssl_error.log
LogLevel warn
CustomLog /var/log/apache2/dp7_ssl_access.log "combined"
</VirtualHost>

Adding SSL to my website

I have the following virtual hosts config:
listen 80
listen 443
servername "example.com"
serveradmin "email#example.com"
namevirtualhost *:80
namevirtualhost *:443
directoryindex index.html index.php
options -indexes -multiviews +followsymlinks
<directory /Volumes/dev1/http>
allowoverride all
</directory>
<virtualhost *:80 *:443>
servername example.com
serveralias www.example.com
documentroot "/Volumes/dev1/http/example"
rewriteengine on
SSLCertificateFile "/Volumes/dev1/ssl/_ssl-cert.crt"
SSLCertificateKeyFile "/Volumes/dev1/ssl/_ssl-privatekey.crt"
SSLCertificateChainFile "/Volumes/dev1/ssl/_ssl-csr.crt"
</virtualhost>
Of course example.com is just an ... example.
All is well if I access http://example.com, but if I try to access the HTTPS version I get
Safari can’t open the page “https://example.com/” because Safari
can’t establish a secure connection to the server “example.com”.
The _ssl* files are all in place and running httpd -t from Terminal returns Syntax OK.
What am I doing wrong? Thanks!
This what I'm using (only the vhosts section), omitting the FCGID, suexec and PHP specific parts:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com/htdocs"
<Directory "/var/www/example.com/htdocs/">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from All
</Directory>
ErrorLog "/var/www/example.com/error.log"
CustomLog "/var/www/example.com/access.log" combined
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
DocumentRoot "/var/www/example.com/htdocs"
<Directory "/var/www/example.com/htdocs/">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from All
</Directory>
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/apache/ssl/example.com.crt
SSLCertificateKeyFile /etc/apache/ssl/example.key
SSLCertificateChainFile /etc/apache/ssl/gd_bundle.crt
ErrorLog "/var/www/example.com/error.log"
CustomLog "/var/www/example.com/access.log" combined
</VirtualHost>