Tuesday, July 17, 2012

ads block plus freebsd

#fetch

wget -O /usr/local/etc/squid/ad_block.txt 'http://pgl.yoyo.org/adservers/serverlist.php?hostformat=squid-dstdom-regex&showintro=0&mimetype=plaintext'

# squid.conf

## disable ads ( http://pgl.yoyo.org/adservers/ )
acl ads dstdom_regex "/usr/local/etc/squid/ad_block.txt"
deny_info http://192.168.3.2/fill.png ads
http_access deny ads


squid -k parse
squid -k reconfigure

Automating with cron

Lastly, you may want to setup and cron job to get the latest list every few days. The site you get the ad list from (pgl.yoyo.org) updates their ips every 3 days or so nn average. With a cron job running you can make sure you have the latest list. Below is a cron job line to get the ad servers list every 3 days at 5:35am (0535).
#minute (0-59)
#|   hour (0-23)
#|   |    day of the month (1-31)
#|   |    |   month of the year (1-12 or Jan-Dec)
#|   |    |   |   day of the week (0-6 with 0=Sun or Sun-Sat)
#|   |    |   |   |   commands
#|   |    |   |   |   |
#### refresh squid's anti-ad server list
35   5    *   *   */3 /scripts_dir/ad_servers_newlist.sh >> /dev/null 2>&1





No comments: