Squid 根据请求的 URL 选择父级?

Osa*_*IRY 3 url proxy squid

我有一个直接连接到互联网的基本鱿鱼配置,我需要一种根据 URL 使用父节点的方法。

例如:

  • 我将其配置为使用本地代理,将其链接到本地​​计算机以获取任何带有 .local TLD 的 URL
  • 如果用户请求http://www.google.com/ ,它会直接转到 google.com 端口 80
  • 如果用户请求http://server1.local/ ,它将使用本地代理访问LAN 上名为 server1 的计算机。

这是一个可以通过 DNS 解决的简化示例,但我正在做一些更复杂的事情。

我尝试用谷歌搜索这方面的结果,但大多数结果都是无关紧要的。谢谢。

Zor*_*che 5

来自鱿鱼常见问题解答


cache_peer_domain 指令允许您指定某些域的某些缓存同级或父级:

#  squid.conf - On the host: sv.cache.nlanr.net
#
#  Format is: hostname  type  http_port  udp_port
#
cache_peer electraglide.geog.unsw.edu.au parent 3128 3130
cache_peer cache1.nzgate.net.nz          parent 3128 3130
cache_peer pb.cache.nlanr.net   parent 3128 3130
cache_peer it.cache.nlanr.net   parent 3128 3130
cache_peer sd.cache.nlanr.net   parent 3128 3130
cache_peer uc.cache.nlanr.net   sibling 3128 3130
cache_peer bo.cache.nlanr.net   sibling 3128 3130
cache_peer_domain electraglide.geog.unsw.edu.au .au
cache_peer_domain cache1.nzgate.net.nz   .au .aq .fj .nz
cache_peer_domain pb.cache.nlanr.net     .uk .de .fr .no .se .it
cache_peer_domain it.cache.nlanr.net     .uk .de .fr .no .se .it
cache_peer_domain sd.cache.nlanr.net     .mx .za .mu .zm
Run Code Online (Sandbox Code Playgroud)

上面的配置表明,对于 uk、de、fr、no、se 域,缓存将使用 pb.cache.nlanr.net 和 it.cache.nlanr.net,对于 mx、za 域,缓存将使用 sd.cache.nlanr.net 、mu 和 zm,以及 au、aq、fj 和 nz 域的 cache1.nzgate.net.nz。


示例鱿鱼配置文件中有关cache_peer_domain的注释。

#  TAG: cache_peer_domain
#       Use to limit the domains for which a neighbor cache will be
#       queried.  Usage:
#
#       cache_peer_domain cache-host domain [domain ...]
#       cache_peer_domain cache-host !domain
#
#       For example, specifying
#
#               cache_peer_domain parent.foo.net        .edu
#
#       has the effect such that UDP query packets are sent to
#       'bigserver' only when the requested object exists on a
#       server in the .edu domain.  Prefixing the domain name
#       with '!' means the cache will be queried for objects
#       NOT in that domain.
#
#       NOTE:   * Any number of domains may be given for a cache-host,
#                 either on the same or separate lines.
#               * When multiple domains are given for a particular
#                 cache-host, the first matched domain is applied.
#               * Cache hosts with no domain restrictions are queried
#                 for all requests.
#               * There are no defaults.
#               * There is also a 'cache_peer_access' tag in the ACL
#                 section.
#
#Default:
# none
Run Code Online (Sandbox Code Playgroud)