Daily tip

How to transparently redirect HTTP requests on port 80 to a http proxy on port 8080?

By using the iptable nat

First pre-requisite is enabling IP forwarding on the system

#echo “net.ipv4.conf.all.forwarding =1”>>/etc/sysctl.conf && sysctl -p

Then issue the below iptable command

#iptables -t nat -A PREROUTING -p tcp –dport 80 -j REDIRECT –to-port 8080