5

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.

2 Answers 2

5

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

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

2
  • Can you comment why you are thinking of using pound? What are the advantages? And maybe you can provide an example config file, you use in your system?
    – rubo77
    Feb 20, 2016 at 21:32
  • Pound is designed to be a reverse proxy. It is optimized only for this use. I did not used it as the apache performance was acceptable for our traffic. Feb 21, 2016 at 21:44
0

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.

3
  • 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, 2010 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. Dec 22, 2010 at 14:28
  • This sounds realy strange. What if a user contacts your server with a request for a domain you have not configured in your hosts file? I think this solution is only a dirty hack, that shold not be used in production environments!
    – rubo77
    Feb 20, 2016 at 21:31

You must log in to answer this question.