If you have a web server and you are suddenly faced with an overload of traffic to your site and you want to buy some time before you re-engineer your site with or without the cloud computing options in mind, you can build a quick reverse proxy squid server to help you out. It will take one hour of your time (assuming you already have an account with Amazon, if not then about 2 hours) and you can have a full reverse proxy server running. This will permit your site more breathing room by caching all requests and serving them to subsequent users. It is a powerful mechanism but needs to be thought out completely if used as a long term solution.
First Install squid server on a linux instance (if using Amazon EC2), you can use publicly available ami (ami-cb52b6a2). After you launch this server just follow the steps below to install the squid service:
First get the software in the server:
Unzip, untar, and change directory to the squid distribution:
gunzip squid-3.0.STABLE13.tar.gz
tar xvf squid-3.0.STABLE13.tar
cd squid-3.0.STABLE13
If you need detailed instructions look into the INSTALL and README file within this directory, but if you trust the words you are reading or you are in a hurry just configure and make with the commands below:
./configure –prefix=/usr/local/squid
make all
make install
wait for a message similar to:
Build Successful.
At this point you have the squid installed and you are a few commands away of having your own quick reverse proxy to buy you some time to re-engineer your site, or at least to save some processing power in your server. All has been installed in /usr/local/squid which we will call squid_home.
- Your configuration files are in squid_home/etc
- Your squid script to start/stop is in squid_home/sbin
- Your squid cache and log files are in squid_home/var
First, go to your configuration files directory (squid_home/etc) and modify your squid.conf file and enter the following directives or lines of configuration:
http_port 80 accel defaultsite=original.server.com
cache_peer original.server.com parent 80 0 no-query originserver name=myAccel
acl our_sites dstdomain .contentpilot.net
http_access allow our_sites
cache_peer_access myAccel allow our_sites
cache_peer_access myAccel deny all
This next step is more a note than something you have to do. Squid is very particular about running processes as root, so you have to be very specific about who is going to run the processes and have permissions to access the log and cache directories. The next set of instructions will make sure that you don’t receive the permission denied errors that many IT professionals have to deal with.
cd /usr/local/squid/
ls -lhd var/
if var is owned by user and group root like this:
drwxr-xr-x 4 root root 4.0K Mar 25 23:55 var/
Then you want to run the following commands:
chown -R nobody:nobody var
Now you are ready to start the cache and start the server.
cd /usr/local/squid/sbin
./squid -z
./squid
and browse to the public dns of your cloud instance, this will immediately take you to the URL in your squid.conf original.server.com.
Please let me know your thoughts or if you think there is something missing let me know so I can add it.


HiVery useful tutorial, thanks. One step you didnt mention was changing the port that Apache listens on? I see that you have set squid to listen on port 80.The issue I am getting is I have changed apache to listen on port 8080 and I cant get that to work.I have updated the apache config, reset apache and when I load my.site:8080 it doesnt work.I have added 8080 to the security group as well, did you have a similar problem?ThanksAndrew
Im getting these error:
checking whether the C++ compiler works…no
Configure: error: in ‘/root/squid-3.1.19/lib/libTrie’:
configure: error: C++ compiler cannot create executables
So i install squid from webmin