Running multiple squid instances on Ubuntu
December 3, 2008 at 7:00 pm | Posted in http | 3 CommentsTags: squid, ubuntu
As described in earlier posts, our standard web application setup at work is TurboGears behind squid as transparent caching proxy behind Apache. One of the reasons for this setup is that we want fine granular control over the services.
Since we already decided to run each application in its own application server, we want to keep things separate in the squid layer as well. Which brings us to the challenge of running multiple squid instances. It turns out this isn’t too hard to do, reusing most of the standard squid installation on ubuntu.
- Create a link to have the squid deamon available under a different name:
cd /usr/local/sbin
ln /usr/sbin/squid squid2
- Create directories for logs and cache files:
mkdir /var/log/squid2
chown proxy:proxy /var/log/squid2
mkdir /var/spool/squid2
chown proxy:proxy /var/spool/squid2
- Create the configuration in
/etc/squid/squid2.conf, specifyingpid_filename,cache_dirandaccess_login particular. - Create an init script. We started out with the one installed with the package and only had to apply the following changes:
# diff /etc/init.d/squid2 /etc/init.d/squid
8,10c8,9
< NAME=squid2
< CONF=/etc/squid/$NAME.conf
< DAEMON=/usr/local/sbin/$NAME
---
> NAME=squid
> DAEMON=/usr/sbin/squid
13c12
< SQUID_ARGS="-D -sYC -f $CONF"
---
> SQUID_ARGS="-D -sYC"
38c37
< sq=$CONF
---
> sq=/etc/squid/$NAME.conf
82c81
< $DAEMON -z -f $CONF
---
> $DAEMON -z
- And install the init script running
.
update-rc.d squid2 defaults 99
Advertisements
3 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a Reply
Create a free website or blog at WordPress.com.
Entries and comments feeds.



What about snmpd?
Comment by Benjamin Goodacre— June 29, 2012 #
Cannot really answer this. I’ve moved to varnish as cache proxy in the meantime.
Comment by Robert Forkel— June 29, 2012 #
This looks perfectly good to me. It makes sense. I need to run both a forward and backward proxy on the same machine and I’m going to give this a try.
The issue I have with running only one instance of squid, I cannot browse and have a web server at the same time. Many sites somehow get directed by the proxy to my own webserver, and then I get a “page not found” message, or I see my own home page. I can’t see any way to make squid allow access from my work computer and deny it at the same time :-) Therefore I need two squids and two configurations.
Comment by Wastrel— August 16, 2017 #