1

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.

2 Answers 2

3

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?

2
  • Well, I don't want to run the app as root, so I can't get hold of a lower port.
    – CBA
    Jan 15, 2013 at 15:09
  • 2
    Actually on Linux there are ways around that limitation, see for example the answer here: stackoverflow.com/questions/413807/…
    – Magnus
    Jan 15, 2013 at 15:10
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .