SSL and regular VHost on the same server [duplicate]
- by Pascal Boutin
This question already has an answer here:
How to stop HTTPS requests for non-ssl-enabled virtual hosts from going to the first ssl-enabled virtualhost (Apache-SNI)
1 answer
I have a server running Apache 2.4 on which run several virtual hosts. The problem I noticed is that if I try to access let's say https://example.com that have no SSL setuped, apache will automatically try to access the first VHost that has SSL activated (which is litteraly not the same site). How can we prevent this strange behaviour, or in other words, how to say to Apache to ignore SSL for a given site.
Here's sample of what my .conf files look like :
<VirtualHost foobar.com:80>
DocumentRoot /somepath/foobar.com
<Directory /somepath/foobar.com>
Options -Indexes
Require all granted
DirectoryIndex index.php
AllowOverride All
</Directory>
ServerName foobar.com
ServerAlias www.foobar.com
</VirtualHost>
<VirtualHost test.example.com:443>
DocumentRoot /somepath/
<Directory /somepath/>
Options -Indexes
Require all granted
AllowOverride All
</Directory>
ServerName test.example.com
SSLEngine on
SSLCertificateFile [...]
SSLCertificateKeyFile [...]
SSLCertificateChainFile [...]
</VirtualHost>
With this, if I try to access https://foobar.com chrome will show me a SSL error that mention that the server was identifying itself as test.example.org
Thanks in advance !