Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com Feb 21 '10 at 21:02

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

add comment

3 Answers

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
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.