Due to limited number of IPs, several domains are resolved into the same IP address. However, these domains may not all run on the same webserver, VM, or even dedicated machine. Therefore, I would like to route the domains at the point of entry into the private network to the right place on condition of the domain in the url.

How can I do this?

4 Answers 4


Most routers/firewalls allow to redirect traffic based on a certain port, e.g. all SMTP traffic (port 25) is redirected to

But if you have multiple servers to handle your traffic (1 server per domain). You need to install something like a reverse proxy (nginx supports this for HTTP, IMAP, POP3). For instance, all traffic to port 80 is redirected to which runs nginx and depending on the host name will redirect to either localhost or

  • +1 Nginx is perfect for this as it doesn't use much memory and was designed to handle large numbers of requests. It's pretty easy to setup on most distros.
    – Frozenskys
    Aug 12, 2010 at 13:32
  • +1 Apache is definitely overkill. A simple Nginx proxy will get the job done. Aug 12, 2010 at 15:38
  • I have installed nginx. It was very easy to install and configure and works very good.
    – txwikinger
    Oct 7, 2010 at 20:09

I am unsure if I fully understand your question. If I do, you have multiple machines running as HTTP servers behind NAT. When some request arrives, you want to forward it to one of your servers, right?

If you are using apache and mod_rewrite, you might be able to pull it this way:

  1. http://www.linuxquestions.org/questions/linux-networking-3/apache-forward-request-to-another-box-264864/

  2. http://www.sematopia.com/2007/09/apache-forwarding-requests-to-another-server/


  • I don't think I can use rewrite to the ip-address since this would prevent me to use multiple domains in one VM, however, I probably can rewrite into local sub domains.
    – txwikinger
    Aug 11, 2010 at 18:25

I have done something similar using the ProxyPass directive under mod_proxy in Apache.

First of all, use Name-based Virtual Hosting to allow different domains to be host different sites using the same IP, then for the domains that associated to an internal webserver, you have a config like so:

# Within your VirtualHost definition
ServerName somedomain.com
ProxyPass /
ProxyPassReverse /

This will result in all requests to http://somedomain.com be transparently proxied to an internal site hosted on



I was looking for the same thing a while ago. Never got around to do it but here is what I though might work.

use the mod_proxy module and use the noproxy directive.


  • I used to have troubles with mod_proxy, but I might try this again.
    – txwikinger
    Aug 11, 2010 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .