Posted by: Xjlittle
centos, ftp, http, https, Linux, proxy, proxy cache, squid, squid.conf, unix, web proxy, windows, Yum
Here is a quick start plan for installing the squid-cache.org proxy server. Squid is a caching proxy server that uses HTTP, HTTPS and FTP for caching web pages from the internet. By caching web pages locally the squid server helps you save on bandwidth and increases page response time for web surfing.
When you first open the squid configuration file it can be overwhelming with over 4000 lines. Many of these are comments but there are still hundreds of configuration choices. I am going to reduce these down to a solid foundation which will get you up and running quickly. This will give you some time to study the other configuration choices that may be necessary for your use. For most people some form of the configuration entries that we use here will be enough to control and proxy your web access.
Squid can be installed on Linux, Unix or Windows. For our purposes here we are installing on Centos 5.x.
Let’s get started:
Install the Squid package
yum install squid
cd to the configuration directory
The default squid config file contains over 4000 lines. Remove the comments so that the file
is a workable size
Copy the squid.conf file to dist.conf.squid to preserve the comments for reference
cp squid.conf dist.squid.conf
The following sed command edits the squid.conf file in place removing comments and empty lines
sed -i.tmp '/^#/d; /^$/d' squid.conf
This will produce a file that contains the following entries:
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
access_log /var/log/squid/access.log squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
http_reply_access allow all
icp_access allow all
After doing this you will need to add some lines to the squid file for your environment
acl our_networks src / /
as in 192.168.1.0/24 192.168.2.0/24
Save your changes and exit the squid.conf file.
Create the squid cache directories in /var/spool/squid
Set squid to start on reboot
chkconfig squid on
service squid start
This should work out of the box after pointing the clients to the correct proxy server and port.
Additional configuration directives can be issued through the /etc/sysconfig/squid file and the /etc/init.d/squid script.
I hope this helps you get squid up and running quickly. Enjoy!