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

Imagine I have 10 different domains. All these domains have an A record to a single IP Address. There are ten different services hosted on this one IP. Let's assume they listen from port :80 to :90. The default port of the used protocol is :80 and I can't force the users to append an :82 to the domain name.

And here's the problem: I want to internally forward the :80 depending on the used domain name.

  • --> :80
  • --> :81
  • --> :82
  • --> :83
  • ...

I googled around and came across iptables. Is this what I'm looking for?

share|improve this question
What is running the domains? Windows, Linux? – Dave M Mar 5 '12 at 19:49
What webserver are you using? Are these domains actually domains, or subdomains/"hosts"? You may want to have a looking into Virtual Hosts. – NcA Mar 5 '12 at 19:50
What is the reason for using different ports rather than just setting up host header values? (Win) – Paul Ackerman Mar 5 '12 at 19:54
I'm using the latest Ubuntu Version and have real domains. And I'm not talking about HTTP, actually it's Minecraft. – buschtoens Mar 5 '12 at 21:09
Unless the minecraft protocol provides an equivalent of the HTTP Host: header, you're SOL. Get more IPs. – womble Mar 5 '12 at 21:39
up vote 3 down vote accepted

Generally this can not be done like that. When the client connects via TCP and/or UDP the server has no information on what domain the client used to request the server's IP address.

Since you are mentioning port 80 you could be talking about HTTP traffic. In that case this distinction can be made since the HTTP protocol also transfers the selected domain name. You could use a HTTP server like Apache and configure a virtual host for each domain that acts as a reverse proxy and forwards the traffic to the correct port. A configuration like this could look something like that:

<VirtualHost *:80>

    ProxyPass / http://server-ip:81/

For this to work the modules proxy and proxy_http need to be activated.

share|improve this answer
Okay, I finally accepted your answer, because in generally for HTTP this is truethy. But you can't do that with - let's say - Minecraft, which doesn't implement the domain into its protocol. – buschtoens Jul 24 '12 at 1:37

You can do exactly what you ask using a proxy or loadbalancer such as haproxy. But if you just want to host multiple sites on the same IP then using headers would be the standard method.

If you are trying to host multiple SSL sites on the same IP then neither of these methods will work because the header and the url are encrypted.

share|improve this answer
Server Name Indication means that you can now host multiple SSL sites on one IP address as long as you don't care about anyone on Windows XP or anything older than IE8. – Ladadadada Mar 5 '12 at 20:44
Doesn't work when the protocol doesn't provide any sort of server name indication, as the OP has (finally) clarified. – womble Mar 5 '12 at 21:38
Plus there still is not enough widespread support for it yet to be relied upon. – JamesRyan Mar 6 '12 at 10:48

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.