Rerouting traffic from port 80 to another port on a single ip
- by zam
I have a server with multiple IP addresses associated with it. I'm trying to run a node.js web server (which I do not want to run as root), using only one of those ip addresses (it would be very bad if the traffic from all the ip addresses were forwarded).
Through searching superuser, it looked like this could be possible with iptables:
How to setting up iptables for traffic fowarding on port 80 from specific sources
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 --source 212.333.111.222 -j REDIRECT --to-port 9020
However, I do not understand why eth0 is needed.
According to:
http://blog.softlayer.com/2011/iptables-tips-and-tricks-port-redirection/
this could be done with:
iptables -t nat -A PREROUTING -p tcp --dport 2525 -j REDIRECT --to-ports 25
What is the correct way of forwarding traffic from a single ip on port 80,
lets say 111.111.111.111:80 to another port on the same server, lets say 111.111.111.111:8765?
thanks for your help!