Apache/2.4.6 (CentOS)
For a while now, I've had a catchall page setup for my Apache server so bots would not crawl my main site unless they had my domain name.
Recently however, I noticed this no longer works with my config. When loading the page by IP address (let's say 10.20.20.10), I get the main site (let's say mysite.net) instead of the catchall.
The config looks like this:
<VirtualHost _default_:80>
ServerName default
# More config ...
</VirtualHost>
<VirtualHost _default_:443>
ServerName default
# More config ...
</VirtualHost>
<VirtualHost 10.20.20.10:80>
ServerName mysite.net
# More config ...
</VirtualHost>
<VirtualHost 10.20.20.10:443>
ServerName mysite.net
# More config ...
</VirtualHost>
Running apachectl -S
revealed to me that it is not being loaded as the default:
10.20.20.10:443 is a NameVirtualHost
default server mysite.net (/etc/httpd/sites-enabled/01-mysite.conf:24)
port 443 namevhost mysite.net (/etc/httpd/sites-enabled/01-mysite.conf:24)
*:80 localhost (/etc/httpd/sites-enabled/00-catchall.conf:2)
*:443 localhost (/etc/httpd/sites-enabled/00-catchall.conf:16)
I was able to find a way to have my catchall load by default, but it required that I changed my catchall to the same listen IP as my main virtual host. Not the most ideal solution. I'd imagine changing all vhosts to * would also do it, but that's not ideal either.
Based on observation, it appeared like httpd prefers a closer match and takes an IP match over "*". Can anyone shed light on why Apache does not load the first vhost and what might fix this?