Squid is an open source tool used as a proxy server. This may be utilized to speed up internet use by caching visited pages and serving up the cache when users on the network request a previously visited page. It can also be used to do some web filtering – black-listing (blocking sites) or white-listing (only allowing certain sites) using user-defined lists.
If you want to take a different route with web filtering than plugging in good or bad domains yourself, there are third-party tools such as SquidGuard. SquidGuard will provided you blacklists that are updated on a frequent basis. The advantage to using a tool like this is you may not know all the websites that should be blocked. This tool uses blacklists in categories, i.e. gaming sites, auction sites, pornography, and a number of other categories.
Here, however, I will demonstrate how to set up some simple filtering with Squid without any additional tools. It’s easy!
Done on: Ubuntu Linux
FIRST:
Download and run Squid. I used apt-get, which is the Ubuntu (i.e. Debian) package manager. The advantage of using this is that it handles all dependencies for you, where downloading the source and compiling it to install it yourself may not.
sudo apt-get install squid
Once that is done, take a look at the config file it installed by default in /etc/squid.
sudo vim /etc/squid/squid.conf
Next, find the part of the file that talks about access lists. You can get there quickly with one of the following:
/Access List [or] 430gg
If you are not familiar with vim (my editor of choice), the slash “/” serves as a find command, and the 430gg tells the editor to go to line 430 (which is about where the ACL section should start). Here it proceeds to provide instruction on ACL syntax. You can read this if you’d like. Next, jump down a ways to line 656 or so where it starts talking about http_access. The syntax is: http_access allow|deny aclname.
We need to have an acl file to play with in the first place, so quit out of the config file with “:q”.
Create an ACL file where you will plug in the sites to be blocked, and then go ahead and plug in some domains.
touch /etc/squid/bad.acl vim /etc/squid/bad.acl Add domains to the file: .ebay.com .amazon.com
You now have a basic ACL to test. Go to the squid config file (/etc/squid/squid.conf) and add the following to the end of the acl section (should be about line 630):
acl bad dstdomain "/etc/squid/bad.acl"
This tells Squid there is an ACL which we arbitrarily titled “bad” that affects destination domain of web browsing to whatever is found in the /etc/squid/bad.acl file. Now, the final step is to tell Squid to block these websites. In the config file, travel down to the http_access section (about line 680) and find the line: # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS”. After this, add:
http_access deny bad
This line should be followed by:
http_access allow localhost
Save and quit out of the config file. You’re ready to go! Start up the service:
sudo service squid start
Once it is running, open a browser and test it out. Note that you have to point the browser to the proxy to get it to work. In Firefox, this is in Edit > Preferences > Advanced > Network > Settings > Manual proxy configuration > Type in the IP address (or localhost if testing locally) and port 3128, the default port that Squid listens on. Also, click “Use this proxy for all protocols”.
Now, browse to a normal website like google.com and it should perform normally. Next browse to a site that should be blocked (I used ebay.com in the example) and you should see something like this:







