Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a router that forwards all port 80 to a Debian web server, but I want to add another server to that bunch. How could I get debian to say forward anyone trying to access to or what ever (so would go to the standard IP just be forwarded to another local server, such that it will have a FQDN)?

share|improve this question

You could use the proxy_mod and vhosts for apache on the server that gets hit with the traffic first.

The fist virtual host would just serve the local content. The second virtual host would be a proxy for the content stored on the other server. You vhost would be similar to this:

        DocumentRoot /var/www/
        ProxyRequests Off
          Order deny,allow
          Allow from all
        ProxyPass /
        ProxyPassReverse /
share|improve this answer
So would DocumentRoot be where it is on the other server? Or just whatever? – Steven Feb 10 '12 at 13:26
Whatever, proxy will take over anyway, but I think you must provide the field for the config-check to be happy. – Bart De Vos Feb 10 '12 at 13:29

Port forwarding works with IP addresses and ports, not hostnames, so in short - you can't. Presuming you have multiple DNS entries pointing to the same public IP address, the router would somehow have to inspect the HTTP requests to decide which internal webserver to send it to - which is out of scope of all home networking gear I would have thought.

The only way you could do this would be to have multiple public IPs, with each one being forwarded to a different webserver internally, or to port forward a different port (say, 81) for the other webserver.

share|improve this answer
Or, use a proxy-server... This is common practice. – Bart De Vos Feb 10 '12 at 13:22
Which I would have suggested, however the initial question asked about it from a port forwarding point of view. – Andy Smith Feb 10 '12 at 13:24

One of the simplest ways to do this would be to run a reverse proxy, such as haproxy. You can operate this on the Debian server, and then forward on requests to where you desire.

So a brief example: your proxy listens on port 80, and forwards everything for to an apache instance listening on, and everything for to an apache instance on another machine (e.g.

The documentation on the haproxy website is simple to understand so you can apply to your circumstances: Note, that there will be lots of info not relevant to you, as haproxy can do a lot more than this simple task.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.