ubuntu 14.04
Apache/2.4.7
I am posting here conf file for my virtual host and default ssl host. not able to figure what am I doing wrong.
http://<website_url> shows the index of the folder. I want to redirect this to https.
https://<website_url> opens fine.
IMPORTANT: I have not enabled the default SSL site.
cat default-ssl.conf|grep -v "#"
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
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
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
</IfModule>
And here is mywebsite configuration file:
cat www.mywebsite.com.conf|grep -v "#"
<VirtualHost *:443>
ServerName www.mywebsite.com:443
ServerAlias www.mywebsite.com
ServerAdmin abc@mywebsite.com
DocumentRoot /var/www/www.mywebsite.com/html
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
SSLEngine on
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
ErrorLog ${APACHE_LOG_DIR}/ssl.error.log
CustomLog ${APACHE_LOG_DIR}/ssl.access.log combined
</VirtualHost>
VirtualHostthat is the same as 443VirtualHost. I guess non-secureVirtualHostwithServerName www.mywebsite.comandDocumentRoot /var/www/www.mywebsite.com/html. If you need to redirect both, you need to define two 443 VirtualHost. – Lety Nov 16 '14 at 16:57http://www.dom1.com, https://dev.dom1.com, and http://www.dom2.com. All hosted on same apache server. I am scratching my head and pulling my hairs at the moment. sorry, I am just not getting this virtual-host thing. – Rajeev Nov 17 '14 at 05:24VirtualHoston port 80, one haveServerName www.dom1.comand the other haveServerName www.dom2.comwith different DocumentRoot content. Normal user access these sites with http a see the content. The thirdVirtualHostis on port 443 andServerNameisdev.dom1.com, developers access this site with https protocol and seeDocumentRootcontent. Please tell me if this assertion are right and what does not work or you can not achieve. – Lety Nov 17 '14 at 22:22site 1: <VirtualHost *:80> ServerName www.dom1.com ServerAlias www.dom1.com ServerAdmin rpxx@xx.com DocumentRoot /var/www/www.dom1.com/html...site 2: <VirtualHost *:443> ServerName dev.dom1.com:443 ServerAlias dev.dom1.com ServerAdmin rpxx@xx.com DocumentRoot /var/www/dev.dom1.com/html...site 3: <VirtualHost *:80> ServerName www.dom2.com ServerAlias www.dom2.com ServerAdmin rpxx@xx.com DocumentRoot /var/www/www.dom2.com/html...thx for help @Letizia
– Rajeev Nov 18 '14 at 16:56http://dev.dom1.comare redirected tohttps://dev.dom1.com. Is this what you are trying to do? – Lety Nov 18 '14 at 20:03