I'm not new to apache, but I'm pulling my hair out on this one.
I can't get a 2nd VirtualHost up on a particular IP. It seems to just use the default VirtualHost for that IP.
I have a server which owns two IP addresses. It runs on ports 80 and 443 on both IPs, such that I have four NameVirtualHosts e.g.
NameVirtualHost 1.1.1.1:80
NameVirtualHost 1.1.1.1:443
NameVirtualHost 2.2.2.2:80
NameVirtualHost 2.2.2.2:443
Now I have a default (i.e. file is named such that it would be sourced before the next one) VirtualHost for 2.2.2.2:80 defined as
<VirtualHost 2.2.2.2:80>
ServerAdmin [email protected]
CustomLog /var/log/apache2/ip2-80-access.log combined
ErrorLog /var/log/apache2/ip2-80-error.log
</VirtualHost>
And a 2nd one
<VirtualHost 2.2.2.2:80>
ServerAdmin [email protected]
ServerName foo.example.com
DocumentRoot /var/www/foo.example.com
CustomLog /var/log/apache2/ip2-80-access.log combined
ErrorLog /var/log/apache2/ip2-80-error.log
</VirtualHost>
DNS is set up so that foo.example.com
points to 2.2.2.2
.
But when I try to access foo.example.com/anything
I get a 404 not found. It seems apache is ignoring my 2nd name-based and ip-based virtualhost.
I'm using Apache 2.2 on Debian 6 (Squeeze). Please note: I am not trying to get apache to choose a virtual host for SSL here (I am aware of limitations/SNI etc.), this is standard port 80.