Squid Web Cache Wiki

Squid Web Cache 文档

🔗 将 Squid 配置为针对多个服务进行身份验证

作者:Joseph Spadavecchia

🔗 目录

我们的要求是根据客户端的子网/IP 地址使用不同的身份验证机制。

用例

到目前为止,这通常是通过运行多个 Squid 实例来完成的;但我们的要求是用单个实例来完成。实现这一目标的一种方法是修改 Squid,将客户端的 IP 地址与身份验证信息一起传递。但是,我想在不修改 Squid 的情况下干净地完成这项工作。

我创建了一个始终返回“OK”的自定义身份验证器,并将其链接到外部 ACL。

:information_source: Squid-3.2 捆绑了一个名为 basic_fake_auth 的工具

🔗 Squid 配置

auth_param basic program /usr/local/bin/basic_fake_auth

external_acl_type myAclType %SRC %LOGIN %{Proxy-Authorization} /usr/local/bin/my-acl.pl

acl MyAcl external myAclType

http_access allow MyAcl

:information_source: myAclType 对 %LOGIN 的依赖对于触发身份验证至关重要,因此,设置 %{Proxy-Authorization}

🔗 my-acl.pl

use URI::Escape;
use MIME::Base64;

$|=1;

while (<>) {
  ($ip,$user,$auth) = split();

  # Retrieve the password from the authentication header
  $auth = uri_unescape($auth);
  ($type,$authData) = split(/ /, $auth);
  $authString = decode_base64($authData);
  ($username,$password) = split(/:/, $authString);

  # do the authentication and pass results back to Squid.
  print my_awsome_auth($ip, $username, $password);
}

:warning: 添加你自己的 my_awsome_auth() 版本来执行你需要的身份验证操作。


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

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