I've got multiple named vhosts on an Apache web server (CentOS 5, Apache 2.2.3).
Each vhost has their own config file in
/etc/httpd/vhosts.d and these vhost config files are included from the main httpd conf with...
Here's an example of one of the vhost confs...
NameVirtualHost *:80 <VirtualHost *:80> ServerName www.domain.biz ServerAlias domain.biz www.domain.biz DocumentRoot /var/www/www.domain.biz <Directory /var/www/www.domain.biz> Options +FollowSymLinks Order Allow,Deny Allow from all </Directory> CustomLog /var/log/httpd/www.domain.biz_access.log combined ErrorLog /var/log/httpd/www.domain.biz_error.log </VirtualHost>
Now I when anyone tries to access the server directly by using the public IP address, they get the first vhost specified in the aggregated config (so in my case it's alphabetical order from the
vhosts.d directory). Anyone accessing the server directly by IP address, I'd like them to just get an 403 or a 404.
I've discovered several ways to set a default/catch-all vhost and some conflicting opinions.
I could create a new vhost conf in vhosts.d called 000aaadefault.conf or something but that feels a bit nasty.
I could have a
<VirtualHost>block in my main
vhosts.ddirectory is included.
I could just specify a
DocumentRootin my main
What about specifying a default vhost in
Would having a
<VirtualHost _default_:*> block in my
httpd.conf before I
Include vhosts.d/*.conf be the best way for a catch-all?