Slackware 12.2 - squidGuard / Squid 2.7 ======================================= Public domain ******************************************************************************** ### Installation cd /usr/src wget -c "http://www.squidguard.org/Downloads/squidGuard-1.4.tar.gz" wget -c "http://www.squidguard.org/Downloads/Patches/1.4/squidGuard-1.4-patch-20091015.tar.gz" wget -c "http://www.squidguard.org/Downloads/Patches/1.4/squidGuard-1.4-patch-20091019.tar.gz" tar zxf squidGuard-1.4.tar.gz tar zxf squidGuard-1.4-patch-20091015.tar.gz /bin/mv squidGuard-1.4-patch-20091015/sgLog.c squidGuard-1.4/src/ tar zxf squidGuard-1.4-patch-20091019.tar.gz /bin/mv squidGuard-1.4-20091019/*.in squidGuard-1.4/src/ cd squidGuard-1.4 ./configure --with-squiduser=nobody make && make install mv /usr/local/squidGuard/squidGuard.conf{,.bak} ******************************************************************************** ### /usr/local/squidGuard/squidGuard.conf # First line of squidGuard.conf should not be empty! dbhome /usr/local/squidGuard/db logdir /usr/local/squidGuard/log dest blocked { urllist blocked/urls domainlist blocked/domains expressionlist blocked/expressions log blocked.log } acl { default { pass !blocked all redirect http://172.16.20.1/filter.html } } ******************************************************************************** ### /etc/rc.d/rc.squidGuard #!/bin/sh # # /etc/rc.d/rc.squidGuard # case "$1" in 'start'|'reload') echo 'Reloading squidGuard ...' /usr/local/bin/squidGuard -C all chown -R nobody:nobody /usr/local/squidGuard/db chown -R nobody:nobody /usr/local/squidGuard/log /usr/local/squid/sbin/squid -k reconfigure ;; 'stop') echo 'Stopping squidGuard ...' chown -R root:root /usr/local/squidGuard/db /usr/local/squid/sbin/squid -k reconfigure ;; *) echo "Usage: $0 [reload|stop]" ;; esac ******************************************************************************** ### Commands chmod +x /etc/rc.d/rc.squidGuard mkdir /usr/local/squidGuard/db/blocked chown nobody:nobody /usr/local/squidGuard/db/blocked ******************************************************************************** ### /usr/local/squidGuard/db/blocked/urls farsnews.com/newstext.php mehrnews.com/en ******************************************************************************** ### /usr/local/squidGuard/db/blocked/domains irib.ir iran-newspaper.com irna.com ******************************************************************************** ### /usr/local/squidGuard/db/blocked/expressions (^|[-\?+=/_])(bondage|boobs?|busty?|hardcore|porno?|sex|xxx+)([-\?+=/_]|$) ******************************************************************************** ### Prepare Database /usr/local/bin/squidGuard -C all chown -R nobody:nobody /usr/local/squidGuard/db chown -R nobody:nobody /usr/local/squidGuard/log ******************************************************************************** ### dry-run test echo "http://www.irna.com 10.0.0.1/ - - GET" | squidGuard -c /usr/local/squidGuard/squidGuard.conf -d # will show something like this : Request(default/blocked/-) http://www.irna.com 10.0.0.1/- - - REDIRECT http://172.16.20.1/filter.html 10.0.0.1/- - - ******************************************************************************** ### /usr/local/squid/etc/squid.conf . . url_rewrite_program /usr/local/bin/squidGuard -c /usr/local/squidGuard/squidGuard.conf . . ******************************************************************************** ### /usr/local/squidGuard/squidGuard-logrotate.sh #!/bin/bash PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin" TMP=$(mktemp) LINES="10000" for F in /usr/local/squidGuard/log/blocked.log /usr/local/squidGuard/log/squidGuard.log; do tail -n ${LINES} ${F} > ${TMP} mv ${TMP} ${F} chown -R nobody:nobody /usr/local/squidGuard/log chown -R nobody:nobody /usr/local/squidGuard/db done [ -e ${TMP} ] && rm ${TMP} ******************************************************************************** ### Starting chmod +x /usr/local/squidGuard/squidGuard-logrotate.sh /etc/rc.d/rc.squidGuard start ******************************************************************************** ### crontab -e 00 0 * * * /usr/local/squidGuard/squidGuard-logrotate.sh &> /dev/null ******************************************************************************** ### Log files tail -f /usr/local/squidGuard/log/* ******************************************************************************** _BY: Pejman Moghadam_ _TAG: squid, squidguard_ _DATE: 2010-07-27 13:11:05_