Using Apache as a Proxy for Server 2003
Putting the “geek” in Dawn of the Geeks are two servers I have set up. The first server is running Windows XP with Apache, MySQL, PHP and Subversion. Recently I began developing .Net web sites using C#. Namely the bank site which is used for managing and tracking personal finances. Windows XP only allows a single web-site to run and only has IIS 5.1. Since I have a copy of Windows Server 2003 I decided to put it to use and installed it on another server. That server just has Windows 2003 with II6.
Now the issue is that all port 80 requests go through Apache. So the first step was to install mod_proxy and mod_proxy_html. Now I can point various hosts to the second server. However mod_proxy doesn’t pass along the original host header. It was sending it to the internal IP. Well, IIS 6 needs to know what host it’s serving for as well if you want to run multiple sites.
The trick is to modify your hosts file on the Apache server so that the host name maps to the internal server.
The flow is
bank.dawnofthegeeks.com hits the DNS server and points to the public IP of my router. The router sends the port 80 request to the apache server. The apache server sees that it’s dealing with bank.dawnofthegeeks.com and reverse proxy’s it to bank.dawnofthegeeks.com, however when Windows XP tries to resolve that host name it gets the internal IP from the hosts file rather than the public IP of the router from the DNS servers. So the request gets sent to the IIS server which sees the hostname bank.dawnofthegeeks.com and serves up the correct web back through the proxy.
Through the magic of the hosts file Apache reverse proxies a host to the same host.