ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How to proxy squid

Updated on October 14, 2016

What is Squid

Squid is a proxy server and web cache daemon. It has a wide variety of uses, from speeding up a web server by caching repeated requests; to caching web, DNS and other computer network lookups for a group of people sharing network resources; to aiding security by filtering traffic. Although primarily used for HTTP and FTP, Squid includes limited support for several other protocols including TLS, SSL, Internet Gopher and HTTPS.

Squid was originally designed to run on Unix-like systems, but also runs well on Windows-based systems. Released under the GNU General Public License, Squid is free software.


I think that WINDOWS is a very powerfull OS but i rather prefer LINUX in my case it had prove to be more stable and i can even install it on an old machine with almost no resources. thats why in my humble opinion LINUX beats WINDOWS for server porpouses. Due to that i will assume that you already have a LINUX BOX up and running. (DEBIAN, CentOS, UBUNTU....)

Lets Start

Now, we need to get squid up and running. If you have get to here is cause you know already to install some packages in a Linux machine (Squid come with most of the distribution of Linux), just install squid and lets get moving to the next step. Now, we need to edit the default squid.conf file (the install directory varies from distro to distro in any case you will find it with "locate" command). The squid.conf file is heavily commented. In fact, some of the best documentation available for squid is in the squid.conf file. After you get it all up and running, you should go back and reread the whole thing. But for now, let's just get the minimum required. Find the following directives, uncomment them, and change them to the appropriate values:

httpd_accel_host virtual

httpd_accel_port 80

httpd_accel_with_proxy on

httpd_accel_uses_host_header on

* httpd_accel_host virtual - This tells the accelerator to work for any URL that it is given (the usual usage for the accelerator is to inform it which URL it must accelerate)

* httpd_accel_port 80 - Informs the accelerator which port to listen to, the accelerator is a very powerful tool and much of its usage is beyond the scope of this section, the only knowledge required here is that this setting ensures that the transparent proxy accesses the websites we wish to browse via the correct HTTP port, where the standard is port 80.

* httpd_accel_with_proxy on - By default when Squid has its accelerator options enabled it stops being a cache server, to reinstate this (this is obviously important as the whole purpose behind this configuration is a cache server) we turn the httpd_accel_with_proxy option on

* httpd_accel_uses_host_header on - In a nutshell with this option turned on Squid is able to find out which website you are requesting

conf file

Here is the complete listing of squid.conf for your reference (grep will remove all comments and sed will remove all empty lines,

# grep -v "^#" /etc/squid/squid.conf | sed -e '/^$/d'

OR, try out sed

# cat /etc/squid/squid.conf | sed '/ *#/d; /^ *$/d'


hierarchy_stoplist cgi-bin ?

acl QUERY urlpath_regex cgi-bin \?

no_cache deny QUERY

hosts_file /etc/hosts

refresh_pattern ^ftp: 1440 20% 10080

refresh_pattern ^gopher: 1440 0% 1440

refresh_pattern . 0 20% 4320

acl all src

acl manager proto cache_object

acl localhost src

acl to_localhost dst

acl purge method PURGE


cache_mem 1024 MB

http_access allow manager localhost

http_access deny manager

http_access allow purge localhost

http_access deny purge

http_access deny !Safe_ports

http_access deny CONNECT !SSL_ports

acl lan src

http_access allow localhost

http_access allow lan

http_access deny all

http_reply_access allow all

icp_access allow all


httpd_accel_host virtual

httpd_accel_port 80

httpd_accel_with_proxy on

httpd_accel_uses_host_header on

coredump_dir /var/spool/squid

Iptables configuration

Next, I had added following rules to forward all http requests (coming to port 80) to the Squid server port 3128 :

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

Desktop / Client computer configuration

Point all desktop clients to your eth1 IP address ( as Router/Gateway (use DHCP to distribute this information). You do not have to setup up individual browsers to work with proxies.

Guestbook - Gimme your thoutghs

    0 of 8192 characters used
    Post Comment

    No comments yet.