Squid
Squid
1. Download the following (there may be newer versions, but definitely need db-2.7.7):
* db-2.7.7.tar.gz (http://download.oracle.com/berkeley-db/db-2.7.7.tar.gz)
* squid-2.6.STABLE5-20061110.tar.bz2 (http://www.squid-cache.org/)
* dansguardian-2.9.8.0.tar.gz (http://dansguardian.org/)
* squidGuard-1.2.0.tar.gz (http://www.squidguard.org/)
* A mail server – I use postfix (installed from Mandriva packages).
3. Make user, group, and firewall rules (iptables commands may appear wrapped in two lines):
* groupadd -r squid
* useradd -g squid -d /var/spool/squid -s /bin/false -r squid
* iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --uid-owner squid -j ACCEPT
* iptables -t nat -A OUTPUT -p tcp --dport 3128 -m owner --uid-owner squid -j ACCEPT
* iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --uid-owner exemptuser -j ACCEPT
(change exemptuser)
* iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080
* iptables -t nat -A OUTPUT -p tcp --dport 3128 -j REDIRECT --to-ports 8080
* cd squid-2.6.STABLE5-20061110
* ./configure --enable-icmp --enable-delay-pools --enable-useragent-log --enable-referer-log
--enable-kill-parent-hack --enable-cachemgr-hostname=hostname --enable-arp-acl --enable-htcp
--enable-ssl --enable-forw-via-db --enable-cache-digests --enable-default-err-language=English
--enable-err-languages=English --enable-linux-netfilter --disable-ident-lookups --disable-internal-
dns && make && make install (this is one long wrapped command from ./configure to make
install)
* cd dansguardian-2.9.8.0
* mkdir /usr/local/dansguardian
* ./configure --prefix=/usr/local/dansguardian --with-proxyuser=squid --with-proxygroup=squid
--enable-email=yes && make && make install (./configure command is wrapped)
* mkdir /usr/local/squid/var/cache
* chown -R squid:squid /usr/local/squid/var
* chmod 0770 /usr/local/squid/var/cache
* chmod 0770 /usr/local/squid/var/logs
* mkdir /usr/local/squidGuard
* mkdir /usr/local/squidGuard/log
* chown -R squid:squid /usr/local/squidGuard/log
* chmod 0770 /usr/local/squidGuard/log
* mkdir /var/log/squidguard
* touch /var/log/squidguard/squidGuard.log
* touch /var/log/squidguard/ads.log
* touch /var/log/squidguard/stopped.log
* chown -R squid.squid /var/log/squidguard
* mkdir /var/lib/squidguard
* mkdir /var/lib/squidguard/db
* mkdir /var/lib/squidguard/db/blacklists
* mkdir /var/lib/squidguard/db/blacklists/ok
* chown -R squid:squid /var/lib/squidguard
* cp squid.conf /usr/local/squid/etc/squid.conf
* sample squid.conf settings:
o http_port 127.0.0.1:3128 transparent
o icp_port 0
o htcp_port 0
o redirect_program /usr/local/bin/squidGuard
o cache_effective_user squid
o cache_effective_group squid
o acl all src 0.0.0.0/0.0.0.0
o acl manager proto cache_object
o acl localhost src 127.0.0.1/255.255.255.255
o acl to_localhost dst 127.0.0.0/8
o acl allowed_hosts src 192.168.12.0/255.255.255.0
o acl SSL_ports port 443
o acl Safe_ports port 80 21 443 # http ftp https
o ##acl Safe_ports port 21 # ftp
o ##acl Safe_ports port 443 # https
o ##acl Safe_ports port 1025-65535 # unregistered ports
o acl CONNECT method CONNECT
o acl NUMCONN maxconn 5
o acl ACLTIME time SMTWHFA 7:00-21:00
o deny_info ERR_ACCESS_DENIED_TIME ACLTIME
o #http_access allow manager localhost
o #http_access deny manager
o http_access deny manager all
o http_access deny !Safe_ports
o http_access deny CONNECT !SSL_ports
o http_access allow localhost ACLTIME
o http_access deny NUMCONN localhost
o #http_access allow allowed_hosts
o http_access deny to_localhost
o http_access deny all
o http_reply_access allow all
o #icp_access allow allowed_hosts
o #icp_access allow all
o icp_access deny all
o visible_hostname localhost
* cp squidGuard.conf /usr/local/squidGuard/squidGuard.conf
o change ip gateway address in squidGuard.conf
* cp dansguardia*.conf /usr/local/dansguardian/etc/dansguardian/
* sample dansguardian.conf settings:
o filterip = 127.0.0.1
o filterport = 8080
o proxyip = 127.0.0.1
o proxyport = 3128
o accessdeniedaddress = ‘http://YOURSERVER.YOURDOMAIN/cgi-bin/dansguardian.pl
o mailer = ‘/usr/sbin/sendmail -t’
* sample dansguardianf1.conf settings:
o groupmode = 1
* cp getlists.sh file to /usr/local/bin
* cp etc-shorewall-start /etc/shorewall/start (change user name)
* cp etc-shorewall-stop /etc/shorewall/stop (change user name)
* cp etc-rc.local /etc/rc.local
* chkconfig iptables on
* chkconfig shorewall on
* service iptables restart
* service shorewall restart
* /usr/local/squid/sbin/squid -z (first-time config)
* /usr/local/squid/sbin/squid -N -d 1 -D (test squid, kill when working fine)
* /usr/local/squid/sbin/squid (this also runs squidGuard from "/usr/local/bin/squidGuard")
* /usr/local/dansguardian/sbin/dansguardian
* /usr/local/bin/getlists.sh (takes a very long time, and may need to be killed and run a couple of
times)
* /usr/local/squid/sbin/squid -k reconfigure
* /usr/local/dansguardian/sbin/dansguardian -Q
* test with browser – should be transparent proxy surfing now, works with lynx as well
* set up a mailer for notifications:
* used postfix, pointed it to your mailserver.isp.domain
* postfix needs /etc/postfix/transport and /etc/postfix/generic
* dansguardian.conf calls it with ’sendmail -t’ command
* for non-authenticated use, do not set ‘by user = on’ in dansgaurdianf1.conf
14. Edit squid.conf and set up time based access, to prevent late night surfing (add the following
lines):
Final notes: This probably will not work exactly as posted, especially if you use newer versions
than I posted, so be prepared to tweak. Read through the squid.conf, squidGuard.conf,
dansguardian.conf, and dansguardianf1.conf files for other options and file locations, and refer to
the University of Google for further help with options and error messages. I had to play around with
configure options for a while before I could get squid to compile, so be ready to to the same,
depending on your setup. This all runs on a local box, which is not used to proxy any other
computers – instead, I just do not allow them to use the main computer. I sincerely hope this helps
someone secure their kids’ computers. I have set this up on a friend’s home PC as well, and they are
very happy with the results. Good luck!