This applies to a local port on localhost that your destined port 80 traffic will be routed too instead:

iptables -t nat -I OUTPUT -p tcp –dport 80 -j REDIRECT –to-ports 8123

Make sure you do something like the following (where you specify the interface) if you don’t want requuests to localhost also sent out the proxy:

iptables -t nat -I OUTPUT -o eth0 -p tcp –dport 80 -j REDIRECT –to-ports 8123

Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.