HTTP dispatching based on domain
Hey GUYS,
I have a small problem (with a possible solution), but I'm interested in your opinion/experience if you would do it similar or if you probably know better/easier tools to achieve this.
The problem: I have a single server (gateway) and two virtual machines. Each virtual machine has a separate private IP address and runs a web-server, while each web server should service a distinct web domain, say domain1.net and domain2.net. The gateway server uses iptables rules to forward tcp packets to the appropriate virtual machine, e.g. based on the destination port number. Now, since I want the users of the web domains to NOT use a port different than 80, I am looking for some kind of HTTP dispatching based on the domain requested by the user, though domain1.net:80 should be forwarded to VM1 and domain2.net:80 should be forwarded to VM2.
I think there are a few solutions to this problem:
(1) consolidate to one VM, put both domains on the same web server and use e.g. apaches virtual host functionality -> right, but want to keep the two virtual machines ;-)
(2) add the mod_rewrite plugin to one of the web servers and configure it to do the rewriting -> haven't yet tested it, but could work
(3) put a proxy server (though SQUID) onto the gateway server and use the rewrite functionality of SQUID to redirect the packets to the appropriate virtual machine
My favorite solution is #3, but I am very interested in your experiences with similar problems or how you would solve this before I start diving into SQUID.
Maybe I'm also overseeing the very trivial solution :-)
Thanks for your help,
Andi
|