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 small application running on port 8888, and as a quick fix to remove the need to append the url with the port, I used the iptables program to forward all requests to port 80 to 8888.

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -REDIRECT --to-port 8888

Assuming this is the only web service running on the server, is there anything wrong with the above approach? (performance, maintenance etc...) And could anyone suggest a good alternative?

I am pretty new to server maintenance, so would be interested to hear what experts have to say.

share|improve this question
up vote 3 down vote accepted

iptables IS the way to tell the kernel to forward ports, so there's nothing wrong with that approach at all.

However, if that is the only HTTP server running on the machine, why not just listen on port 80 right away?

share|improve this answer
Well, I don't want to run the app as root, so I can't get hold of a lower port. – CBA Jan 15 '13 at 15:09
Actually on Linux there are ways around that limitation, see for example the answer here:… – Magnus Jan 15 '13 at 15:10
ah, thanks for that. So there is a way. – CBA Jan 15 '13 at 15:19

Your setup uses resources (for conntraq, nat etc.).

The "right way" would be, to fix your app (or configure it) to listen on port 80.

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.