LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   HTTP dispatching based on domain (https://www.linuxquestions.org/questions/linux-server-73/http-dispatching-based-on-domain-867301/)

ForzaItalia2006 03-08-2011 04:24 PM

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

bathory 03-09-2011 12:21 AM

Hi,

If you want to keep both VMs running their own webserver, then go for the reverse proxy scenario (solution 3).
Just a note: Apart from squid, you can also use apache or nginx as a reverse proxy on the gateway.

Regards

ForzaItalia2006 03-09-2011 01:26 AM

Quote:

Originally Posted by bathory (Post 4283662)
If you want to keep both VMs running their own webserver, then go for the reverse proxy scenario (solution 3).
Just a note: Apart from squid, you can also use apache or nginx as a reverse proxy on the gateway.

Thanks for your answer and your recommendations. And thanks for telling the right expression. I didn't yet know that this scenario is called "reverse proxy"!

Andi


All times are GMT -5. The time now is 06:51 AM.