Friday, March 16, 2007

My basic Squid Proxy configuration

A certain Albuemil asked thru a comment on this blog on how I configured my Squid proxy. So here I am sharing what I learned via PLUG mailing list (special mention to AC Perdon for his excellent instructions) on how to configure Squid proxy. Warning: I am no computer expert and so I welcome additional information to enrich my Linux experience.

First install squid via apt-get or synaptic:
sudo apt-get install squid
After installation, edit Squid's configuration file:
sudo gedit /etc/squid/squid.conf
In the /etc/squid/squid.conf file, search and edit the following options/tags:

#TAG:http_port
http_port 3128

#OPTION WHICH AFFECT THE CACHE SIZE
cache_mem (1/4 of the your RAM) MB

(e.g. assuming your RAM is 1Gb then its "cache_mem 250 MB")

#LOGFILE PATHNAMES AND CACHE DIRECTORIES
#cache_dir ufs /var/spool/squid 100 16 256
cache_dir diskd /cache (capacity of your /cache in MB) 16 256

(make sure /cache already exists)

#RECOMENDED MINIMUM CONFIGURATION
acl netxxx src xxx.xxx.xxx.xxx/xxx.xxx.xxx.xxx

(specify your network and netmask e.g. "acl mynet src 192.168.0.0/255.255.255.0)

# AND FINALLY DENY ALL OTHER ACCESS TO THE PROXY
http_access allow netxxx

(e.g. "http_access allow mynet")

#TAG:Visible_hostname
visible_hostname (yourserver name)

#Then i just add these lines after the last lines of the configuration file

ie_refresh on
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

Save the file and then close.

At the terminal, change the ownership of /cache
sudo chown proxy:proxy /cache
Then create swap directories at /cache:
sudo squid -z
Then fireaway squid!
sudo /etc/init.d/squid start
You may now follow the instructions on this blogpost for a transparent proxy using Ipkungfu.

To check if its working, open a web browser on a PC in your LAN and then do the following at the terminal :
sudo tail -f /var/log/squid/access.log
Enjoy Squid!

P.S.: I am using Ubuntu LTS on a Pentium IV 1.7 Ghz 1Gb RAM 120 Gb HB PC.

2 comments:

Rich said...

Looking at the config, this is SQUID 2.5 or 2.6?

Just worth noting because I'm trying to get a setup to work using 2.7.

I don't dare go and install 3.0 to see how they're changed it again!

fishfillet said...

@Rich

This is for 2.5 then. Here's my config for squid 2.6. I now use CentOS 5.3 for my squid box. = http://teqnix.blogspot.com/2009/01/ipkungfu-nat-dhcp-server-transparent.html

Its pretty much the same, but easier. :)