This should be a super simple setup!
I am trying to enable SSL on only a single subdomain. However, when I do this, all of my subdomains and my primary domain end up pointing towards that subdomain's document root.
To be clear, when I point my browser I get the following document roots served:
http://domain.com -> /var/www [GOOD]
http://sub1.domain.com -> /media/large/sub1 [GOOD]
http://sub2.domain.com -> /var/www [Strange, but doesn't bother me. And error message would be better if possible, or a redirect to https.]
https://domain.com -> /media/large/sub2 [BAD]
https://sub1.domain.com -> /media/large/sub2 [BAD]
https://sub2.domain.com -> /media/large/sub2 [GOOD]
Those 2 [BAD] sectors are what's truly bothering me. I don't want people navigating to those URLs to be accessing the sub2
document root.
This is my ports.conf
:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
NameVirtualHost *:443
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
And here are all of my /etc/apache2/sites-enabled
domain.com
:
<VirtualHost *:80>
ServerName domain.com
DocumentRoot /var/www
</VirtualHost>
sub1.domain.com
:
<VirtualHost *:80>
ServerName sub1.domain.com
DocumentRoot /media/large/sub1
</VirtualHost>
sub2.domain.com
:
<VirtualHost *:443>
ServerName sub2.domain.com:443
DocumentRoot /media/large/sub2
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
</VirtualHost>
If it matters, this is on a totally default Ubuntu server.