janosrusiczki
janosrusiczki

Reputation: 1931

Name based virtual hosts serve the same SSL site

On my server I have the following vhost definition:

<VirtualHost *:80 *:443>
  ServerAdmin [email protected]
  ServerName mysite.com
  ServerAlias www.mysite.com
  DocumentRoot /var/www/mysite.com/current/public
  SSLEngine on
  SSLCertificateKeyFile /etc/ssl/ssl.key/myserver.key
  SSLCertificateFile /etc/ssl/ssl.crt/mysite_com.crt
  SSLCertificateChainFile /etc/ssl/ssl.crt/mysite_com.ca-bundle
  <Directory /var/www/mysite.com/current/public>
    Allow from all
    Options -MultiViews
  </Directory>
</VirtualHost>

The site itself works fine, the problem is that if I try any other site (vhost) hosted on the same server with https and skip the warning I get served mysite.com. This wouldn't be a problem for the casual user but I noticed Google tried and actually indexed a ton of URLs on my "other" sites via https which were actually pages from mysite.com and I'm afraid I'll get penalized for duplicate content.

How do I deny the other sites to be served via https?

Upvotes: 1

Views: 48

Answers (1)

janosrusiczki
janosrusiczki

Reputation: 1931

I solved the issue. For further reference this is Ubuntu 12.04.

In /etc/apache2/ports.conf added the following to the <IfModule mod_ssl.c> section:

NameVirtualHost *:443

As per the instructions in the above file, modified in /etc/apache2/sites-available/default-ssl from <VirtualHost _default_:443> to <VirtualHost *:443>.

Then:

sudo a2ensite default-ssl
sudo service apache2 reload

Done.

Upvotes: 1

Related Questions