如何在 TinyProxy 中正确添加 header 以在 Squid 中进行身份验证

How to correctly add header in TinyProxy to authenticate in Squid

我的路由器上有一个 TinyProxy 代理,它将流量发送到不在 LAN 上的外部 parent Squid 代理进行处理。我向 squid 添加了授权,这样它就不会完全向世界开放(如果用户将浏览器指向正常工作的 squid 代理,则用户必须提供用户名和密码)。

查看 TinyProxy 手册页,我可以看到可以通过 tinyproxy 将基本授权 header 信息发送到 Squid parent,但是当我尝试这样做时,它不是正确验证(无浏览器配置。这是一个 transparent 代理),我在 Squid 端收到访问错误。以下是 TinyProxy.conf 手册页的摘录:

AddHeader "X-My-Header" "Powered by Tinyproxy"

如果允许使用 Squid 的用户具有用户名:test 和密码:test1234 密码哈希:123456789 这是我在 TinyProxy.conf 文件中包含的内容:

AddHeader "Proxy-Authorization" "Basic test:123456789"

当我尝试访问 HTTP 站点时,它没有正确验证。格式不对?

也供参考,这是我的squid.conf

auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/passwords
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated

#http_access allow all
http_port 3128

我找到了解决问题的方法。添加一个header时,不是"user:password_hash"的形式,而是base64字符串的形式。我刚刚使用在线转换器 (http://www.tuxgraphics.org/toolbox/base64-javascript.html) 将 "test:test1234" 转换为 "dGVzdDp0ZXN0MTIzNA=="。 TinyProxy 中的 AddHeader 行变为:

AddHeader "Proxy-Authorization" "Basic dGVzdDp0ZXN0MTIzNA=="

而且它的身份验证非常完美!我希望除我以外的其他人发现这很有用,因为我找不到一个 "TinyProxy" 添加 header 的例子。