What is Squid?
Squid is a proxy server and web cache daemon. It has a wide variety of uses, from speeding up a web server by caching repeated requests; to caching web, DNS and other computer network lookups for a group of people sharing network resources; to aiding security by filtering traffic. Although primarily used for HTTP and FTP, Squid includes limited support for several other protocols including TLS, SSL, Internet Gopher and HTTPS.
You can install Squid either by using the package manager of your OS, or by compiling from source.
Installing on CentOS
Yum install squid
This will install Squid version 2.6
Installing on Debian
apt-get install squid3
This installs Squid version 3/3.1
Installing on Ubuntu
aptitude install squid3
Installing from Source
You can download your source version at http://www.squid-cache.org/Versions/ once downloaded run the following installation commands
tar xzf squid-2.6.RELEASExy.tar.gz
./configure --with-MYOPTION --with-MYOPTION2 etc
once the make completes run
If you receive any errors chances are you are missing a component or package that i required to compile the application check the error and install any missing libraries, components or packages.
more details on configure options and settings for the install can be found at the following link http://wiki.squid-cache.org/SquidFaq/CompilingSquid
Reverse Proxy Mode
What is a Reverse Proxy?
An accelerator caches incoming requests for outgoing data (i.e., that which you publish to the world). It takes load away from your HTTP server and internal network. You move the server away from port 80 (or whatever your published port is), and substitute the accelerator, which then pulls the HTTP data from the "real" HTTP server (only the accelerator needs to know where the real server is). The outside world sees no difference (apart from an increase in speed, with luck).
How do I set it up?
Their are multiple ways to configure Squid as a Reverse proxy of Website Accelerator, below is a configuration for a basic setup
Configuring a Basic Reverse Proxy (Website Accelerator)
This configuration covers the basic Reverse Proxy (Accelerator) config. More advanced configurations all build on these basic settings. This configuration is designed for two Servers.
The accel option to http_port should only be specified for 2.6.STABLE8 and later.
First, you have to tell Squid to listen on port 80 (usually), so set the http_port option with the defaultsite option telling Squid it's an accelerator for this site:
http_port 80 accel defaultsite=your.main.website.name no-vhost
accel tells Squid to handle requests coming in this port as if it was a Web Server defaultsite=X tells Squid to assume the domain X is wanted. no-vhost for Squid-3.2 or later disables HTTP/1.1 domain based virtual hosting support. Omit this option for older Squid versions.
Next, you need to tell Squid where to find the real web server:
cache_peer backend.webserver.ip.or.dnsname parent 80 0 no-query originserver name=myAccel
And finally you need to set up access controls to allow access to your site without pushing other web requests to your web server.
acl our_sites dstdomain your.main.website.name
http_access allow our_sites
cache_peer_access myAccel allow our_sites
cache_peer_access myAccel deny all
You should now be able to start Squid and it will serve requests as a HTTP server.
Load balancing of back-end servers
To use Squid as a load balancer you simply need to add the following to your config.
cache_peer ip.of.server1 parent 80 0 no-query originserver round-robin
cache_peer ip.of.server2 parent 80 0 no-query originserver round-robin
You can find a detailed and through FAQ at the Official site for Squid http://wiki.squid-cache.org/SquidFaq