If you want Squid to be part of a hierarchy of proxies or you just want Squid to fetch content not directly from a web server but rather indirectly from another proxy then read on how to do that.
You can use the cache_peer directive to add parent proxies which Squid will ask for content. Furthermore you can control whether content will be fetched directly or indirectly with always_direct or never_direct respectively. For example
cache_peer proxy.some-isp.com parent 8080 0 no-query no-digest never_direct allow all
would tell Squid to always fetch content from the parent proxy, which is located at proxy.some-isp.com:8080. If we wouldn’t use the second directive there may be certain circumstances where Squid would ask directly for content and would ignore the parent proxy; this isn’t what we want.
There are a lot of options available which I don’t want to discuss here, because they are very well documented, but no-query and no-digest say that no ICP requests or cache digests should be send to the parent proxy (read: nagging should be turned off 😉 ).
Multiple parent proxies
If you would like to have more than one parent proxy you can add more cache_peer directives; one for each parent. Now you can define either weight or round-robin to control the way Squid will communicate with the proxies: while weight tells Squid to prefer one cache over another, round-robin tries to spread connections evenly among the defined caches.
First of all a simple example for two parent proxies:
cache_peer proxy.isp1.com parent 8080 0 no-query no-digest default cache_peer proxy.isp2.com parent 8080 0 no-query no-digest
If you define more than one parent proxy you might want to set one as the default proxy, which is used as a last resort.
An example for weight:
cache_peer proxy.isp1.com parent 8080 0 no-query no-digest weight=1 cache_peer proxy.isp2.com parent 8080 0 no-query no-digest weight=2
In this example it is likely that the proxy from the second ISP will be favored over the first one.
And here an example for round-robin:
cache_peer proxy.isp1.com parent 8080 round-robin no-query cache_peer proxy.isp2.com parent 8080 round-robin no-query cache_peer proxy.isp3.com parent 8080 round-robin no-query
All connections to our proxy would be round-robined among these three caches. Because Squid treats all parents equally, it is currently not possible to define a weight here, e.g. to forward 50% of the requests to the first proxy and 25% to the second and third proxy respectively.
This post documents how to configure Squid to use a parent proxy or various parent proxies. Please have a look at the most recent documentation to learn more about the configuration details and features available in the latest version of Squid.
2 thoughts on “Using a parent proxy with Squid”
Pingback: squid proxy
Pingback: Squid as child proxy and cannot service HTTPS requests
Comments are closed.