This is another easy way for installing transparent proxy

First of all, install squid

$ sudo apt-get install squid

Now edit the configuration file /etc/squid/squid.conf.

$ sudo vi /etc/squid/squid.conf

Find this in squid.conf and change it

visible_hostname yourdomain.com (no need)
cache_mgr panayara@gmail.com (no need)
http_port 3128 transparent
always_direct allow all
cache_dir ufs /var/spool/squid 500 16 256

That’s all you need to change on squid.conf

Now create the cache directory by typing

$ sudo squid -z

Now you can restart squid

$ sudo /etc/init.d/squid restart

Finished? NOT YET..

We are now have to set for transparent proxy. Transparent proxy means that we don’t have to enter any proxy address on browser. If we browse a website, we are going to port 80. But with this tutorial, we’re forwarding any connection that’s going to port 80 to our squid server automatically. So let’s start setting this.

$ sudo echo 1 > /proc/sys/net/ipv4/ip_forward

This method is to enabling ip forwarding

Put that script in your startup scripts .

Now you have to put masquerading method so you can forward the connection

$ sudo apt-get install ipmasq

Last step..

$ sudo iptables -A PREROUTING -t nat -p tcp –dport 80 -j REDIRECT –to-port 3128

This command is for forward any request on port 80, will be forwarded to port 3128 (our squid port)

Now you can run transparent squid proxy

$ sudo /etc/init.d/squid start

Now your Transparent Proxy server is ready to work