Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two squid servers, Squid A and Squid B.

Squid A transparently caches for the local network.

I would like to set up Squid A so that on a request for an URL matching a regexp, instead of serving the request as normal, it "redirects" through Squid B so that Squid B serves the request, passes the result back to Squid A which passes it onto the client.

How do I set up the config file for Squid A to do this?

share|improve this question
Buh? ? – tsilb Jul 19 '09 at 17:54
up vote 1 down vote accepted

Use following in squid A configuration (normally /etc/squid/squid.conf)

cache_peer <squid server B IP> parent <server B squid port> 3130 no-query no-digest no-netdb-exchange 

acl otherproxy url_regex "/etc/squid/divert.txt"
cache_peer_access <Squid server B IP> allow otherproxy
never_direct allow otherproxy
cache_peer_access <squid server B IP> deny all

And following in squid B configuration at top of other acls

acl A_proxy src <Squid server A IP>/32
http_access allow A_proxy

After that you can add regular expressions to file /etc/squid/divert.txt and reload squid. The matching URLs will be requested from Server B and not directly.

The reason why I mentioned adding acl on proxy B too is too avoid authentication, connection limit, etc. settings on proxy B affecting clients of proxy A as such problems are very hard to debug. So it is better to allow all requests from proxy A to proxy B. If you want to block something block it in both proxy configurations.

share|improve this answer

you want something like the following in squid A's squid.conf. use it as an example and tweak to suit your exact requirements.

# define squid B as a parent
cache_peer parent 3128 3130 default

# create ACLs for any domains or IP address ranges that you
# don't want to get from the parent (squid B). for example:
acl local_domains domain
acl local_ip dst
always_direct_allow local_domains
always_direct allow local_ip

# and deny direct access to everything else
never_direct allow all
share|improve this answer

Squid specifically has a feature supporting hierarchic organization of proxy servers. The squid manual page has excellent documentation on that topic.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.