Blocking adverts with squid proxy

Ever since I set up a Squid proxy server on my LAN, I’ve noticed a resurgence in adverts on my Android (for which Chrome doesn’t support plugins).

I was looking for a way to do this with Squid, and produced this script which you can run daily as a cronjob.

  1. Create a directory for your scripts and create the new file:

    mkdir -p /opt/scripts
    cd /opt/scripts
    nano squid_adblock.sh
  2. Paste the following into it:
  3. Make it executable and test run it:

    chmod +x squid_adblock.sh
    ./squid_adblock.sh
  4. Check the contents of the blocklist_savefile and if it looks OK, add it to the crontab:

    @daily /opt/scripts/squid_adblock.sh
  5. This, which should be inserted alongside your ACLs:

    acl adblock dstdom_regex "/etc/squid/adblock.list"
  6. This, which should be inserted BEFORE any acl which specifies clients allowed to connect:

    http_access deny adblock

Leave a Comment

Skip to toolbar