Squid tips. Blacklisting spyware & porn sites

Материал из RSU WiKi
Перейти к: навигация, поиск

Some windows users are using "hosts" file for spam/spyware blocking from MVPs project [1]. Conversion of this file to be squid-compatible is described in Chris Davis article [2].

Scripts & mods

/etc/cron.weekly/update-spyware-rules.sh

 #!/bin/bash
 
 #———[ Changelog
 # Created  2007.02.18 by Chris Davis
 # Modified 2007.03.09 by Juriy Strashnov
 
 #———-[ Variables
 URL=http://www.mvps.org/winhelp2002/hosts.zip
 SPYWARE_DIR=/tmp/spyware/
 TEMP_SPYWARE_LIST=$SPYWARE_DIR/temp_spyware_list.txt
 TEMP_SPYWARE_LIST_ZIP=$SPYWARE_DIR/spyware_list.zip
 SQUID_SPYWARE_LIST=/etc/squid/spyware_list_mvps.txt
 
 #———-[ Script
 # If the spyware directory doesn’t exist, create it.
 if [ ! -e $SPYWARE_DIR ]
     then mkdir $SPYWARE_DIR
 fi
 
 # Download the HOSTS file
 wget $URL -O $TEMP_SPYWARE_LIST_ZIP
 
 unzip -c $TEMP_SPYWARE_LIST_ZIP > $TEMP_SPYWARE_LIST 
 
 # Parse the newly downloaded file to work with Squid
 grep 127.0.0.1 $TEMP_SPYWARE_LIST | \
 sed 's/127.0.0.1 //g' | grep -v localhost | \
 cut -d "#" -f 1 | tr -d "\r" > $SQUID_SPYWARE_LIST
 
 # Reload Squid to load the new files
 /etc/init.d/squid reload

squid.conf modifications

 acl SPYWARE_MVPS dstdomain "/etc/squid/spyware_list_mvps.txt"
 http_access deny SPYWARE_MVPS

Примечания

  1. mvps.org: Blocking Unwanted Parasites with a Hosts File
  2. http://www.averageadmins.com/blog/2007/02/25/linux-web-proxy-project/

Ссылки

Личные инструменты
Пространства имён

Варианты
Действия
Навигация
Инструменты