title: How to use iptables in linux to forward http and https traffic to a transparent proxy
body: <p>I have a Ubuntu linux system acting as a gateway system with two interfaces on it. One interface is for the local network and one interface is for the internet. I am able to route traffic through it with no problem at all. I use two <code>iptables</code> rules to forward outbound traffic from the internal interface:</p>
  
  <pre><code>iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
  iptables --append FORWARD --in-interface eth1 -j ACCEPT
  </code></pre>
  
  <p>I now need to create an <code>iptables</code> rule that filters out and redirects all tcp port 80 and 443 traffic leaving my network through the <code>eth1</code> interface and send it to a proxy server that resides on a loopback interface on tcp port 9090.</p>
  
  <p>I have been searching all over SO but I have not been able to find an example that works. Is there an efficient way to do this?</p>