how to squidGuard + squid on freeBSD   February 15th, 2010

Download Berkeley Db from oracle website

cd /usr/local

wget http://download.oracle.com/berkeley-db/db-4.8.26.tar.gz

#tar -zxvf db-4.8.26.tar.gz

#cd db-4.8.26/build-unix

run this command

#../dist/configure –prefix=/usr/local/db/

after that

#make && make install

this will install it in /usr/local/db

go and verify new directories there e.g bin and include etc

if yes then

#cd /usr/local

wget http://www.squidguard.org/Downloads/squidGuard-1.4.tar.gz

unzip it using

# tar -zxvf squidGuard-1.4.tar.gz

# cd squidGuard-1.4

# ./configure –prefix=/usr/local/squidGuard –with-db=/usr/local/db/ –with-sg-config=/usr/local/squidGuard/squidGuard.conf

#make && make install

% cd /usr/local/squidGuard
% vi squidGuard.conf

Copy and paste this for a minimal configuration

#####################################################################
logdir /usr/local/squidGuard/log
dbhome /usr/local/squidGuard/db 

dest bar_adult {
        domainlist bar_adult/domains
        urllist    bar_adult/urls
} 

acl {
        default {
                pass !bar_adult all
                redirect http://127.0.0.1/blocked.php?url=%u
                # if webserver is running on the same system
                # and u have already made a blocked.php file and placed it in webserver root directory
                # if not make a block.html page add what ever u want and make it.
                #redirect http://yourwebserverip/block.html
        }
}

##################################################################################

% cd /usr/local/squidGuard
% mkdir db
% mkdir log
% touch log/squidGuard.log
% cd db
% mkdir bar_adult
% cd bar_adult

now we create the files themselves. Create a file called domains and

fill it with domains – one per line – in the following type format:

Code:

adult_content.com
naughty.com

now create a file called urls and fill it with urls – one per line in the following format:

Code:

foo.com/~adult
bar.com/img/sexy

edit you squid.conf where ever is it

add a line

redirect_program /usr/local/squidGuard/bin/squidGuard

after that

/usr/local/squid/sbin/squid -k reconfigure
/usr/local/squid/sbin/squid -k parse
/usr/local/squid/sbin/squid NCd1

if all is ok reload your squid.

It will work.