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

We have a web server with several apache instances listening on various ports (8080, 80801, 8082 for example).

we currently have an nginx instance listening on port 80 which takes in the requests and then proxies them to the proper instance port by domain name.

Would it be possible to do the same thing with iptables?

share|improve this question

migrated from Feb 21 '10 at 21:02

This question came from our site for professional and enthusiast programmers.

No; there is no concept of "destination domain" at the IP level, only destination IP address, so iptables cannot help you - nginx relies on the requested domain being transmitted as part of the URL in the HTTP request; but you can achieve the effect directly in apache, without requiring the nginx instance.

share|improve this answer

You can't do it. In a HTTP request the "domain" is conveyed in the Host: header which is Layer 7. iptables rules only have access to Layer 4 / TCP level info.

share|improve this answer

A clean way to set this up, if you can afford the additional address usage, is to have each domain point to a different IP address. Then configure all the addresses on this host, and let each instance of Apache bind to the port 80 of a single address (Use the syntax Listen Address:Port ) and you can remove nginx.

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.