Main Content

Virtual hosting and mod_proxy forwarding of different domains (httpd)

Archive - Originally posted on "The Horse's Mouth" - 2009-03-01 09:43:45 - Graham Ellis

Let's say that you want to set up a single web server to look after several domains, but then have parts of those domains served by other 'back room' servers. This diagram give you the picture - a single incoming IP address / server with all the security and logging stuff on it (and probably handing a lot of the general traffic too), but other machine(s) in the background fulfilling other specific roles. I set up a configuration like this yesterday - as part of an httpd and Tomcat Deployment Course.

The main server is Apache httpd (I had it on 192.168.200.214 - see diagram) and it was serving a domain called "devizes". [technical note - devizes.wellho.net or something fully qualifies when you take this out to the internet!]. However, I wanted to add the domains "lavington" and "urchfont" to it, with parts of the Lavington domain forwarded to another server on the same machine, and the entire Urchfont domain forwarded to another machine - 192.168.200.215.

Using Apache 2.2.x, I uncommented the virtual host support line in httpd.conf, and configured the virtual host file in the extra directory ... using mod_proxy to forward my traffic. The Virtual host configuration file, with lots of extra annotation, is available here.

Notice that is doesn't matter what the background servers are running (httpd, Tomcat or something else), or whether they're on the same physical box or a different one. And the whole scheme will easily expand to using balancing with mod_proxy_balancer ... all of which are the subject of other resources you'll find here abouts!