
Squid is a popular web caching proxy server. There is a lot of variety in it. It is primarily designed to run on Linux / Unix-like systems but it can also run on Windows. Squid is supporting FTP, gopher, and HTTP data objects. Squid handles all requests in a single, non-blocking, I/O-driven process.
Squid keeps meta data and especially hot objects cached in RAM, caches DNS lookups, supports non-blocking DNS lookups, and implements negative caching of failed requests.
In this howto I’ll explain about Squid on FreeBSD. We will configure squid as a transparent proxy server the main benefit of this transparent proxy is that you do not need to setup up any proxy setting in client’s browsers to accessing internet.
Installation
Let’s install squid from ports
cd /usr/ports/www/squid make install clean
You must select SQUID_PF or SQUID_IPFW option according to your firewall in the options menu for Enable transparent proxy with PF or IPFW.
Configuring Squid
In the squid configuration we need to define squid port, ACL & cache_dirs
The default port of squid is (TCP) 3128 and we will also use this port. Our local network is 172.16.1.0/24, so We will define an ACL for our local network to work with squid. Make sure you should change your internal IP networks from where browsing should be allowed.
Let’s edit /usr/local/etc/squid/squid.conf
vi /usr/local/etc/squid/squid.conf
Modify or add following squid directives:
http_port 3128 transparent cache_dir ufs /cache 50000 16 256 acl tech_networks src 172.16.1.0/24 http_access allow tech_networks
About Configuration
- http_port: Squid will run on its default port 3128
- cache_dir ufs: I have select /cache directory for squid cache storage
- acl tech_networks: I have defined acl tech_networks for my local network
- http_access: Then allow all traffic from tech_networks acl.
You can printout the complete listing of squid.conf for your convenience. This command will remove all comments and printout your configuration.
Run this command on terminal
grep -v "^#" /usr/local/etc/squid/squid.conf | sed -e '/^$/d'
The output should be like this.
acl tech_networks src 172.16.1.0/24 http_access allow tech_networks acl all src all acl manager proto cache_object acl localhost src 127.0.0.1/32 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access deny all icp_access deny all http_port 3128 transparent hierarchy_stoplist cgi-bin ? cache_dir ufs /cache 50000 16 256 access_log /usr/local/squid/logs/access.log squid refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320 acl shoutcast rep_header X-HTTP09-First-Line ^ICY.[0-9] upgrade_http0.9 deny shoutcast acl apache rep_header Server ^Apache broken_vary_encoding allow apache coredump_dir /usr/local/squid/cache
Now everything is configured. In the next step we will create our initial squid cache_directories then start squid proxy server.
Before creating cache_directories we need to change the ownership of /cache directory to squid user.
Lets’ create our cache_directories
chown -R squid:squid /cache/ squid -k parse squid -z
If there is no error and you see a message like this Creating Swap Directories, that means you have successfully install and configured squid. We need to add squid into /etc/rc.conf file so whenever system boot squid automatically run.
vi /etc/rc.conf
Add this line into rc.conf file
squid_enable="YES"
Let’s start our squid proxy server
/usr/local/etc/rc.d/squid start
You don’t need any proxy setting into your browser just point http traffic to your proxy server in your firewall configuration file. Then you can test your proxy server either is working or not using this command.
tail -f /usr/local/squid/logs/access.log
The above command will printout all incoming request from your client.
That’s all. I hope you will like this howto, your comments will be highly appreciated.

Had configure SQUID for Windows. I was a linux guru back in the old days until such time when SQUID was released to support Windows and an office consult me of setting up their web proxy cache I tried using this and it‚Äôs awesome. In my page I’ve put step by step configuration on Windows with scripting on squid.conf on how to block sites.
hI bro,
may i know what version of squid you are using?
thanks
paul