Debian: Squid Block AdServers

Some us of don’t want to run PiHole, but do wish to run an AdBlock system either in DNS or integrated with our proxy server. https://pgl.yoyo.org/adservers/#plaintext provides a solution to both. This entry will describe how to integrate an Adblock list into a Squid proxy environment.

Download the following script and make sure its located somewhere you can execute it

# cd /etc/squid
# wget https://pgl.yoyo.org/adservers/scripts/squid/update-squid-adservers.txt -O /etc/squid/update-squid-adservers.sh

Make sure that the script is run e.g. once a week so that the adblock list is updated /etc/cron.weekly/update-squid-adblock

#!/bin/sh
/etc/squid/update-squid-adservers.sh >/dev/null

Make sure the file is executable

# chmod +x /etc/cron.weekly/update-squid-adblock

Add the following in the acl section of squid configuration file
/etc/squid/squid.conf

acl ads dstdomain "/etc/squid.adservers"
http_access deny ads

Run the update script:

# /etc/squid/update-squid-adservers.sh

Configure your webbrowser and test the adblocker

https://d3ward.github.io/toolz/adblock.html

there are also quite a few lists available from firebog, however these will require making your own script to add to the Squid lists.