apt-get install squidguard
Installazione dei pacchetti necessari:
mkdir /home/www && cd /home/www
hg clone http://hg.thundersystems.it/siti/firewall.thundersystems.it
cd firewall.thundersystems.it/site-packages
hg clone http://hg.thundersystems.it/jumbo-new/jumbo-core
hg clone http://hg.thundersystems.it/django/django-1.2.2
hg clone http://hg.thundersystems.it/jumbo-new/jumbo-proxy
hg clone http://hg.thundersystems.it/django/south-trunk
svn co http://django-tinymce.googlecode.com/svn/trunk django-tinymce
Configurazione local_settings e database:
cd /home/www/firewall.thundersystems.it/firewall_thunder
cp local_settings_sample.py local_settings.py
Modificare la configurazione di squid (andremo a sostiutire il file squid.conf con un file nostro personalizzato)
cp /etc/squid/squid.conf /etc/squid/squid.conf.bck
cp /home/www/firewall.thundersystems.it/site-packages/jumbo-proxy/proxy/utils/squid.conf /etc/squid/squid.conf
Entrare nel file nuovo file squid.con e modificare la linea visible_hostname con il nome della macchina
Modificare :
visible_hostname nome-macchina
Con al posto di nome-macchina il nome della macchina
/etc/init.d/squid restart
Per abiltiari il proxy bisogna scommentare la riga PROXY_REDIR_PORT=3128 nel file /etc/argo/fw.conf
vim /etc/argo/fw.conf
Scommentare la riga:
PROXY_REDIR_PORT=3128
pyrewall restart
Controllare se le acl sono abilitate
Nel file /etc/fstab deve essere presente la parola acl nella partizione /
Se non e' presente installare il pacchetto:
apt-get install acl
e modificare il file /etc/fstab in questo modo:
Da: "/dev/xxx / reiserfs defaults"
A: "/dev/xxx / reiserfs defaults, acl"
mount -o remount /dev/xxx
Note
utente_apache —> Rappresenta l’utente con cui girera’ l’applicazione in apache Nel nostro esempio useremo come utente www-data
Aggiungere le ACL:
setfacl -R -m u:www-data:rxw /etc/squid/
setfacl -R -m u:www-data:rxw /var/lib/squidguard/db/
setfacl -d -R -m u:www-data:rxw /var/lib/squidguard/db/
setfacl -R -m g:www-data:rxw /var/lib/squidguard/db/
setfacl -d -R -m g:www-data:rxw /var/lib/squidguard/db/
setfacl -R -m u:www-data:rxw /var/log/squid
setfacl -d -R -m u:www-data:rxw /var/log/squid
Settare i permessi al file di log di squidGuard:
chmod 777 /var/log/squid/squidGuard.log
Permettere all’utente con cui gira il sito di poter accedere senza la richiesta della password ai comandi per lo start/restart/stop do squid
Aggiungere nel file /etc/sudoers la seguente linea (visudo):
www-data ALL=NOPASSWD:/etc/init.d/squid,/usr/sbin/squid
Se non ci sono le blacklist scaricarle:
cd /tmp/
wget ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidguard_contrib/blacklists.tar.gz
Scompattarle dentro la cartella /var/lib/squidguard/db:
cd /var/lib/squidguard/db
gzip -d /tmp/blacklists.tar.gz
tar xfv /tmp/blacklists.tar
rm blacklists.tar
Creare le directory per le my_blackliste e my_whitelist:
cd /var/lib/squidguard/db
mkdir my_blacklists && mkdir my_whitelists && mkdir my_blacklists/my_black && mkdir my_whitelists/my_white
touch my_blacklists/my_black/domains && touch my_blacklists/my_black/urls && touch my_blacklists/my_black/expressions
touch my_whitelists/my_white/domains && touch my_whitelists/my_white/urls && touch my_whitelists/my_white/expressions
cd /var/lib/squidguard/
chown -R proxy:proxy db/
Bisognera’ poi compilare tt le blacklists. Per far cio’ bisognera’ creare una acl tramite l’interfaccia e poi dare il comando:
squidGuard -C all
Questo comando passera’ in rassegna tt le blacklist presenti nel file di configurazione di squidguard e le compilera’.
Riaggiungere i permessi ai nuovi file .db creati da squid
cd /var/lib/squidguard/
chown -R proxy:proxy db/
Test funzionamento delle black list:
echo "http://www.youporn.com 10.0.0.1/ - - GET" | squidGuard -c /etc/squid/squidGuard.conf -d
Aggiungere un link simbolico al file logs_reader in /usr/sbin:
cd /usr/sbin/
ln -s /var/lib/python-support/python2.5/jungle/apps/proxy/logs_reader.py logs_reader
Aggiungere al file /etc/crontab la seguente riga:
0 * * * * root logs_reader -s ovpn.settings
Nel file /etc/argo/fw.add aggiungere la seguente linea:
iptables -I FORWARD -p tcp --dport 1863 -j REJECT
Nel file /etc/squid/squid.conf aggiungere queste 4 linee:
acl msn_req req_mime_type -i ^application/x-msn-messenger
acl msn_rep rep_mime_type -i ^application/x-msn-messenger
http_access deny msn_req
http_reply_access deny msn_rep
Note
L’abilitazione/disabilitazione di msn avviene commentando/scommentando le ultime 2 righe. Commentadole, msn risultera’ attivo e quindi usabile, scommentandole non vi si potra’ accedere.