Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running Ubuntu 12.10 and I have the following 4 VirtualHost entries in /etc/apache2/apache2.conf

The 4 VirtualHost entries are for 2 separate sites, test.example.com and test2.example.com, one entry each for HTTP and one for HTTPS.

<VirtualHost *:443>
   DocumentRoot /var/www/test
   ServerName test.example.com
   # Other settings goes here
</VirtualHost>


<VirtualHost *:80>
   DocumentRoot /var/www/test
   ServerName test.example.com
   # Other settings goes here
</VirtualHost>

<VirtualHost *:443>
   DocumentRoot /var/www/test2
   ServerName test2.example.com
   # Other settings goes here
</VirtualHost>


<VirtualHost *:80>
   DocumentRoot /var/www/test2
   ServerName test2.example.com
   # Other settings goes here
</VirtualHost>

My problem When I save and restart apache, I get this warning:-

* Restarting web server apache2
[Sun Feb 17 18:30:09 2013] [warn] _default_ VirtualHost overlap on port 443, the first has precedence
 ... waiting [Sun Feb 17 18:30:10 2013] [warn] _default_ VirtualHost overlap on port 443, the first has precedence

And I get the contents of /var/www/test when I open both test.example.com and test2.example.com

Any idea what the problem is?

share|improve this question
    
Is NameVirtualHost *:443 in your configuration? –  faker Feb 17 '13 at 18:47
    
@faker, not it was not. I added it and the problem was solved :) Thanks. If you add it as an answer, I can accept it. Also can you tell me why adding it was necessary, since I hadnt added NameVirtualHost *:80 for HTTP and still both the VirtualHosts on port 80 woked? –  Sparky Feb 17 '13 at 18:59

1 Answer 1

up vote 2 down vote accepted

You need to add NameVirtualHost *:443 for it to work.
NameVirtualHost *:80 must also be in your configuration, it is probably set by default, but I don't use Ubuntu so I'm not sure in which file.

Also a word of advice:
Running multiple HTTPS sites on a single IP might have it's drawbacks, specifically older clients (IE8/Windows XP) will not support SNI.
It may make perfect sense in your situation (only for testing, *.example.com wildcard certificate is being used, etc.) but you should be aware of this.

share|improve this answer
    
Thank you faker. –  Sparky Feb 17 '13 at 19:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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