iptables doesn't redirect http traffic to my Squid proxy!
I think you are missing the destination port, try following
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3128
Without dport, you are forwarding traffic with destination port 3128 to local port 3128. What you want is traffic with destination port 80 forward to local port 3128.
Additionally, to show nat rules, use
iptables -t nat -L
However, the above rules will not work for a transparent proxy setup on the same machine of the browser, because PREROUTING chain alters packges before routing from a remote client and it will not do anything for locally generated packets. Thus we should use OUTPUT chain for packets locally generated which are going out from the system.
Try following instead
iptables -t nat -A OUTPUT -p tcp -m owner ! --uid-owner proxy --dport 80 -j REDIRECT --to-port 3128
It will only redirect traffic for processes other than the ones owned by proxy
user.
Without -m owner ! --uid-owner proxy
, it will not work because the rules will also caught the proxy server outgoing traffic and end up in a loop.