Squid Web Cache Wiki

Squid Web Cache 文档

🔗 具有多个后端 Web 服务器的反向代理

🔗 将不同请求发送到不同的后端 Web 服务器

要控制哪个 Web 服务器(cache_peer)接收哪些请求,可以使用 cache_peer_access 指令。这些指令限制了可以发送到给定对等服务器的请求。

例如,网站托管在两台服务器上,如下所示:

🔗 Squid 配置

🔗 按域切换

使用 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

使用 cache_peer_domain 的方式相同(自 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: 此指令已在 Squid-4 中移除。

🔗 域名以外的其他标准

还可以使用其他 acl 类型,例如 urlpath_regex,来根据域名以外的其他标准路由请求。

对于我们的示例,网站的 /foo 目录单独托管在第二台服务器上

:warning: 请记住,缓存是基于请求的 URL 而不是请求转发到的对等服务器,因此如果内容被缓存,请不要使用依赖于用户的 acl。


⚠️ 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.

类别: ConfigExample

导航:网站搜索网站页面分类🔼 向上