Configure Squid

After finishing installation, we will now learn how to set basic configuration for squid. You can follow steps explained below:

1. configuration can be done by editing file squid.conf which by default resides on directory /usr/local/squid/etc if the installation is done through source files compilation and installed on directory /usr/local/squid. If you installed from a binary package, the configuration file will reside on /etc/squid. Or you are not sure, you can check the location of the configuration file by do following command:

rpm -qc squid

2. If you want to check the location of files and documentation related to squid, you can type following command:

rpm -ql squid

3. Then open the configuration file by using a text editor, type your command accordingly based on the location of squid configuration file

vi /usr/local/squid/squid.conf or vi /etc/squid/squid.conf

you can use other editor such as pico, kate, so on

4. Find the configuration tag and modified its value accordingly. There are some basic tag that need to be understand well in the first hand.

  • http_port
This setting defines port number used by squid to listening requests from client application. The default value is 3128, and can be configure more than one port. Example:
http_port 3128 8080
  • cache_dir
This setting defines the location and parameter of the cache storage. The parameters that can be defined by this tag are disk file system, cache location, size of cache, the number of top level directory, and the number of low level directory. Example:
cache_dir ufs /usr/local/squid/var/cache 100 16 256
Above settings means the file system used is ufs, the location of the cache is /usr/local/squid/var/cache, the cache's size is 100 MB, the number of top level directory is 16, and the low level has 256 directories.
  • acl
Access control in squid can be managed by first creating access list using acl tag. This tag defines access list that will be used in access control configuration using http_access tags. Example:
acl my_network src 192.168.0.0/255.255.255.0 or
acl my_network src 192.168.0.0/24
Above acl defines access list for all hosts in an internal network with Net id 192.168.0.0 and subnet mask 255.255.255.0. This is the basic access list configuration if you want to configure the access right of your internal network hosts.
  • http_access
While acl tag defines the alias for a batch of hosts then http_access tag defines the access right to access the proxy services. Example
http_access allow my_network
http_access deny all
Above configuration tells proxy to allow access from any host defined in access list named my_network, and deny access from all other hosts. (Note the http_access deny all must always put on the last line of http_access tag. This because the http_access tag in squid.conf is proceeded sequentially from the first line to the last line.)
  • cache_mgr
This setting defines email address for the proxy cache server administrator. If problems or system crash occur, a message will be sent to this email address. Example:
        cache_mgr root@cicc.org
  • cache_effective_user
This setting defines which user is authorized to run a squid server. Default installation will create user named squid. Thus mostly the setting will be
cache_effective_user squid
  • cache_effective_group
This setting defines which group is authorized to run a squid server. Default installation will create group named squid. Thus mostly the setting will be
cache_effective_group squid
  • ftp_user
This setting defines password used for anonymous user when proxy try to download files from a FTP server using anonymous account.
ftp_user root@cicc.org