1

I have a VPS from DO with one ip address. I'm managing multiple domain via Apache Virtual Hosts, and now, I must setup a virtual host with SSL support. I created a self-signed ssl certificate to test virtual host.

I can see content of example1.com with https when I connected https://example1.com but I can see content of example1.com too when I connected to https://example2.com although example2.com has not ssl configuration at server's conf file.

example1.com configuration:

<VirtualHost *:80>
    basic example1.com http conf such as DocumentRoot, ServerName
</VirtualHost>
<VirtualHost *:443>
    example1.com https conf

    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
    SSLCertificateFile /path/to/example1.com-ssl-server.crt
    SSLCertificateKeyFile /path/to/example1.com-ssl-server.key
</VirtualHost>

example2.com configuration:

<VirtualHost *:80>
    basic example2.com http conf such as DocumentRoot, ServerName
</VirtualHost>
2

but I can see content of example1.com too when I connected to https://example2.com although example2.com has not ssl configuration at server's conf file.

That happens precisely because example2.com doesn't have a SSL configuration. By default, if there's no VirtualHost with the exact server name, then Apache will use the first VirtualHost for the same port.

(That's why Debian, for example, uses "000-default.conf" for the default vhost, so that it would always go before anything else.)

  • So should I set ssl configuration to all virtualhosts which I don't want to have https connection? – Kaan Kölköy Nov 27 '15 at 16:22
  • @KaanKölköy: Well, these days you do want a https connection for all of them. Really. But the other way is to have a special "fallback" VirtualHost with just an error message (and no ServerName), and put it before all other vhosts. – grawity Nov 27 '15 at 21:13
  • I already have a fallback virtualhost both for *:80 and *:443, but this time, I cannot connect to example1.com. Did I understand you wrong? – Kaan Kölköy Nov 27 '15 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.