Blocking access to sites when using Squid

A quick and easy way to block access to certian sites using Squid

First create a text file containing all the blocked sites eg:


Then create an ACL in squid.conf for this file:

acl blockedsites dstdomain "/etc/squid/blockedsites.txt"

Next, deny access to this ACL in squid.conf

http_access deny blockedsites

Make sure you add the above line ABOVE your allow line otherwise the filter will not work, for example:

http_access deny blockedsites
http_access allow localhost  

Now restart Squid and test, if you need to edit the blockedsites.txt file you will need to restart squid after for the changes to take effect.

Last updated: 22/10/2005