Location, Location, Location: Tips for Storing Web Site Files
Subject:   Virtual hosts
Date:   2003-05-28 03:18:19
From:   elektron
an empty "NameVirtualHost" is unnecessary. All you need is "NameVirtualHost *". Or, in Sodium's case,

NameVirtualHost *:80
NameVirtualHost *:8080

because some ISPs suck. Port 80 is still used just because it feels proper.

<VirtualHost> is equivalent to <VirtualHost> because Apache only looks at the IP in <VirtualHost>. The "Host" header (or server portion of the request line) is compared to ServerName. And when virtualhosting to the rest-of-world, unless you have a static ip or a nameserver that tells you who you are when you get connected, it's best to use <VirtualHost *>.

If you do, however, use <VirtualHost *>, all requests that don't match a VirtualHost will match the first wildcard VirtualHost. To stop this from happening, the first virtualhost should be

<VirtualHost *>

to set the default DocumentRoot and stuff to everything you painstakingly configured in the rest of httpd.conf.

And thirdly, you just need one line for each ip address in the hosts file, e.g. " localhost me myself i". lookupd doesn't consult /etc/hosts by default in 10.1.5, though, so it's a lot of playing with netinfo (i don't remember if you could click a box to tell it to consult the flat files).

I don't worry about Apple overwriting my httpd.conf, mainly because I set apache2 to run instead.