Within Apache I had a vhost set up with ServerName host1.example.com
Within /etc/hosts there is an entry for host1
127.0.1.1 host1.example.com host1
And in /etc/hostname
host1
This is the Debian/Ubuntu way of creating an FQDN.
Apache seems to have a problem when serving content for a virtual host that has the same FQDN as the server itself.
When running nginx with a vhost for host1.example.com it has no problem picking up the Host header and using the correct vhost.
But when using Apache it has problems, it always uses 000-default. Deleting 000-default makes it switch to the next vhost and deleting all but the vhost file for the domain that I want to work finally makes it work.
NameVirtualHost is set to *
There are no error messages in the logs, no overlapping virtualhosts and the vhost config is perfectly fine.
<VirtualHost *>
ServerAdmin webmaster@localhost
ServerName host1.example.com
DirectoryIndex index.php index.htm index.html
DocumentRoot /var/www/host1.example.com
<Directory />
Options FollowSymLinks Includes -Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Anyone have any ideas?
Edit:
apache -t -D DUMP_VHOSTS output:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:* is a NameVirtualHost
default server the.server.fqdn (/etc/apache2/sites-enabled/000-default:1)
port * namevhost the.server.fqdn (/etc/apache2/sites-enabled/000-default:1)
port * namevhost host1.example.com (/etc/apache2/sites-enabled/host1.example.com:1)
Syntax OK