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

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

2 Answers 2

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
2  
Actually on Linux there are ways around that limitation, see for example the answer here: stackoverflow.com/questions/413807/… –  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

 
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.