Squid Web Cache wiki

Squid Web Cache documentation

πŸ”— Reverse Proxy with Multiple Backend Web Servers

πŸ”— Sending different requests to different backend web servers

To control which web servers (cache_peer) gets which requests the cache_peer_access directives is used. These directives limit which requests may be sent to a given peer.

For example the websites are hosted like this on two servers:

πŸ”— Squid Configuration

πŸ”— Switching on Domains

Using cache_peer_access:

cache_peer ip.of.server1 parent 80 0 no-query originserver name=server_1
acl sites_server_1 dstdomain www.example.com example.com
cache_peer_access server_1 allow sites_server_1

cache_peer ip.of.server2 parent 80 0 no-query originserver name=server_2
acl sites_server_2 dstdomain www.example.net download.example.com .example.net
cache_peer_access server_2 allow sites_server_2

The same using cache_peer_domain (deprecated since Squid-3.2):

cache_peer ip.of.server1 parent 80 0 no-query originserver name=server_1
cache_peer_domain server_1 www.example.com example.com

cache_peer ip.of.server2 parent 80 0 no-query originserver name=server_2
cache_peer_domain server_2 download.example.com .example.net

:warning: This directive has been removed in Squid-4.

πŸ”— Other Criteria than Domain

It is also possible to route requests based on other criteria than the host name by using other acl types, such as urlpath_regex.

For our example here the websites /foo directory alone is hosted on a second server:

:warning: Remember that the cache is on the requested URL and not which peer the request is forwarded to so don’t use user dependent acls if the content is cached.


⚠️ Disclaimer: Any example presented here is provided "as-is" with no support
or guarantee of suitability. If you have any further questions about
these examples please email the squid-users mailing list.

Categories: ConfigExample

Navigation: Site Search, Site Pages, Categories, πŸ”Ό go up