Saturday, March 28, 2009

Squid Cache: Filtering



Kernel & Firewall:

#echo 1 > /proc/sys/net/ipv4/ip_forward
#/sbin/iptables -t nat -A POSTROUTING -s [network]/[subnet] -o [interface] -j MASQUERADE
#/sbin/iptables -t nat -A PREROUTING -p tcp -s [network]/[subnet] --dport [http_port] -j REDIRECT --to-ports [squid_port]

squid.conf:

http_port [squid_port] transparent

acl allowed_client src "/path/to/allowed_client"
acl blocked_url url_regex "/path/to/blocked_url"
acl blocked_file url_regex -i "/path/to/blocked_file"

http_access deny !allowed_client
http_access deny blocked_url
http_access deny blocked_file
http_access allow allowed_client

Squid's log rotate with crontab:

0 0 1 * * /path/to/squid -k rotate

this will rotate squid's log for 1 month interval.

Reconfigure Squid

#/patch/to/squid -k reconfigure

Happy caching...

Squid