Operating System - Linux
1833238 Members
2679 Online
110051 Solutions
New Discussion

redirect the whole HTTP traffic using proxy

 
'chris'
Super Advisor

redirect the whole HTTP traffic using proxy

hi

howto redirect the whole HTTP traffic using proxy ?

I have tried using iptables:

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.0.5:3128

but it doesn't work !

this machine is a vpn gateway and should redirect the whole HTTP traffic to the proxy.

p.s
I don't have a transparent proxy.

greetings
chris
3 REPLIES 3
Alexander Chuzhoy
Honored Contributor

Re: redirect the whole HTTP traffic using proxy

I did it once with reverse proxy.
All http that comes to proxy is redirected to internal web server- below is the link to a guide:

http://www.visolve.com/squid/whitepapers/reverseproxy.php

Steven E. Protter
Exalted Contributor

Re: redirect the whole HTTP traffic using proxy

Shalom Chris,

Often this mistake is made.

Before forwarding traffic, which is what your statement does, check the file /etc/sysctl.conf

It must have ipv4 forwarding set to yes.

Then try again, that alone may be the issue.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Michal Toth
Regular Advisor

Re: redirect the whole HTTP traffic using proxy

some distros do not reference ip_forwarding in sysctl,.. use cat cat /proc/sys/net/ipv4/ip_forward to get your current status,.. though if that is indeed a gateway, then it should be turned on

next you can do some debugging with logging packets:

iptables -t nat -A PREROUTING -p tcp --dport 80 -j LOG --log-prefix " (INC_HTTP)"
... DNAT line here ...
iptables -t nat -A POSTROUTING -p tcp --dport 80 -j LOG --log-prefix " (OUT_HTTP)"