Apache Virtual Hosts for Dynamic DNS

By David Efflandt

My goal was to configure apache with a default virtual host, so anyone connecting to my webserver by IP or reverse name would hit a dead end with separate logging from other vhosts. This was primarily to keep the port scanners and multitude of Windows worms from filling my normal server logs.

This is an exercise in dynamic virtual web hosting. NameVirtualHost is used to specify IP's that will have multiple vhosts, but since my internet IP is unknown when apache is started, I have to use wildcards.

It should also work for a box behind firewall/nat if port 80 is forwarded to it and the box has an interface with its internet name (does not need to be internet IP). I will not detail multiple internal webservers at this time. But if you only have 1 internet IP and your LAN is masqueraded or nat'd, you might look into apache docs for mod_proxy and ProxyPass.

I had a minor problem in SuSE 7.3 in that it prefers that we do not tamper with its apache conf files, and just add our own conf to a separate file. Since it set my hostname as ServerName, any requests to my hostname fell into the default vhost instead of the vhost for my hostname. I got around that by changing the ServerName to the private name for my LAN nic, so it recognized that the request was not for the default ServerName.

So this is my supplemental vhost.conf for:

  1. default - dead end with separate logging (worms, probes)
  2. realhost - vhost for hostname
  3. efflandt - alternate vhost
  4. localhost - local vhost
  5. localdomain - LAN vhost

Related Files:

Dynamic DNS
for your domain [ Local Home | Internet Home ]