Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have one public IP address, one router and multiple servers behind the router.

I would like to forward differing domains (All using HTTP) through the router to different servers.

For example:

example1.com      =>  192.168.0.110
example2.com      =>  192.168.0.120
foo.example2.com  =>  192.168.0.130
bar.example2.com  =>  192.168.0.140

I understand that this could be accomplished using Port Forwarding, but I need all hosts running on port 80.

I found some information about IP Masquerading, but I found this difficult to understand, and I am not sure if it is what I am after.

Another solution I have found is to direct all traffic to Reverse Proxy server, which forwards the requests onto the appropriate server. What about iptables?

I am using a Billion 7404 VNPX router. Is there a feature that this router has that can accomplish this?

Are these my only options? Have I missed something completely? Is one recommended over the others?

I have searched around but I don't think I am hitting the correct keywords.

share|improve this question

2 Answers 2

The best solution would be to user a HTTP reverse proxy. For this you can use:

  • apache with mod_proxy
  • pound
  • squid
  • nginex

We are using apache with mod_proxy, but I am thinking to go with pound.

As a hardware appliance you can use a Cisco Content Service Switch. See: http://www.cisco.com/en/US/products/hw/contnetw/ps792/index.html

share|improve this answer

I've had an idea, and I'd like to know if anyone has some feedback on it.

If I use the Reverse Proxy idea, I think I can resolve the issue quite simply. I am already using Nginx on the other servers, so this is my server of choice for a Reverse Proxy.

At the router, I will forward all incoming connections on port 80 to my Reverse Proxy server. I will have Nginx running on this server with the following configuration file:

server {
    listen *:80;
    location / {
        proxy_pass    http://$host;
    }
}

What this appears to do is proxy the request to the same host. But here's the trick, in my /etc/hosts file I will map all of the domains to their internal IPs.

182.168.0.110 example1.com
182.168.0.120 example2.com
182.168.0.130 foo.example2.com
182.168.0.140 bar.example2.com

So the Reverse Proxy server will route the requested host to the same host, but at this point it should look up the local hosts file, and map that to the internal IP address. It also means I can "set and forget" the Nginx configuration file.

A potential problem is if a local hostname has not been configured, then the Reverse Proxy will send the request back out to the Internet. However, I think NAT will stop this from getting stuck in an infinite loop.

This solution seems to work in my head, and on paper, but I won't be able to set this up for a while.

Can anybody see any reason why this will not work?

Thanks.

share|improve this answer
    
I think this might work, but you MAY be in for a surprise if people contact your reverse proxy and do assorted "nasty" things to it. –  Vatine Dec 22 '10 at 11:39
1  
it is working. We are using in this way to have the same hostname from the browser and also in the request from the proxy towards the website. The browser is resolving the domain using DNS and the reverse proxy is resolving the same domain using hosts. And you will have an infinite number of requests if you forgot to configure it in the hosts and the reverse proxy is allowed to browse the Internet. And better is to have one IP configured for the DNS that is resolving the hosts for Internet and an internal IP for intranet. IN this way the local requests does not go trough the proxy. –  Mircea Vutcovici Dec 22 '10 at 14:28
    
Thanks for your help guys. –  user10270 Dec 23 '10 at 1:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.