2

I have domain "domain1.com" which uses ip "1.1.1.1" and is configured:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName domain1.com
.......
</VirtualHost>
<VirtualHost 1.1.1.1:443>
        ServerAdmin webmaster@localhost
        ServerName domain1.com
.......
</VirtualHost>

I tried to add new domain name which uses same IP, "domain2.com"

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName domain2.com
.......
</VirtualHost>
<VirtualHost 1.1.1.1:443>
        ServerAdmin webmaster@localhost
        ServerName domain2.com
.......
</VirtualHost>

But when i restart apache it says:

[warn] VirtualHost 1.1.1.1:443 overlaps with VirtualHost 1.1.1.1:443, the first has precedence, perhaps you need a NameVirtualHost directive

And when i tried to open any of them, 1st domain certificate showed as if there is no SSL, 2nd domain was okay.

3

you need to add NameVirtualHost while doing virtual hosting

NameVirtualHost 1.1.1.1:443
<VirtualHost 1.1.1.1:443>
# ...
</VirtualHost>

if you want to receive requests on all interfaces, you can use an argument of *:443

you can take help from Apache Documentation.

add like:

Listen 80
Listen 443

NameVirtualHost 1.1.1.1:80
NameVirtualHost 1.1.1.1:443

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName domain1.com
.......
</VirtualHost>
<VirtualHost 1.1.1.1:443>
        ServerAdmin webmaster@localhost
        ServerName domain1.com
.......
</VirtualHost>

 <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName domain2.com
.......
</VirtualHost>
<VirtualHost 1.1.1.1:443>
        ServerAdmin webmaster@localhost
        ServerName domain2.com
.......
</VirtualHost>
4
  • What if i have 2 separated virtual hosts files (domain1.conf, domain2.conf) under sites-available, do i need to add that line NameVirtualHost 1.1.1.1:443 to both files? – MohammedSimba Nov 3 '15 at 14:25
  • 1
    i have not tested but i think it is not required . you can keep it any one file . it simple means is you ip listen on port 443 and 80. conceptually is is not needed . – pl_rock Nov 3 '15 at 14:27
  • please test this and share with me also . i am also interested to see what will happen. – pl_rock Nov 3 '15 at 14:29
  • I tested it, it considered one of them as unused [warn] NameVirtualHost 1.1.1.1:443 has no VirtualHosts, one of them is enough – MohammedSimba Nov 3 '15 at 14:31

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.