I am trying to forward all outgoing traffic from port 80 to port 8080 using iptables and I tried the following rule, though it did not work:iptables -t nat -A OUTPUT -p tcp --dport 80 -j  REDIRECT --to-port 8080Also, for incoming traffic I need a rule that forward port on the same host not to be as proxy.
forward outgoing traffic port using iptables
linux;centos;iptables
You will need that under nate.g*nat:PREROUTING ACCEPT:POSTROUTING ACCEPT :OUTPUT ACCEPT-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080you can run this: with example of forwarding 80 to 8080 and so on... Incoming on 80 to 8080iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080Outgoing on 80 to 8080 iptables -t nat -A POSTROUTING -p tcp --dport 80 -j SNAT --to-ports 8080Note: I haven't tested this.