First of all, install squid by using our lovely packaging management “apt-get”
glen@lumanau:~$ sudo apt-get install squid
After all finished, let’s edit the configuration. Use your favorite editor. For this tutorial, I’m using “vi” as the editor
glen@lumanau:~$ sudo vi /etc/squid/squid.conf
Find this in squid.conf and change it
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
glen@lumanau:~$ sudo squid -z
Now you can run the squid
glen@lumanau:~$ sudo /etc/init.d/squid start
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.
glen@lumanau:~$ 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
glen@lumanau:~$ sudo apt-get install ipmasq
Last step..
glen@lumanau:~$ 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
glen@lumanau:~$ sudo /etc/init.d/squid start
Congratulations….!!! You have successfully install your Transparent Proxy on your server..

Source :