关闭。此问题不符合 Stack Overflow 准则。它目前不接受答案。我们不允许在 Stack Overflow 上提出有关专业服务器或网络相关基础设施管理的问题。您可以编辑问题,使其成为 Stack Overflow 的主题。 7年前关闭。改进这个问题
我目前在 acl 中使用 ip,我想使用用户名和密码来执行此操作。
这是我在 Ubuntu 14.04 上设置基本身份验证所必须做的(在其他任何地方都没有找到指南)
基本鱿鱼配置
/etc/squid3/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
# Choose the port you want. Below we set it to default 3128.
http_port 3128
请注意 basic_ncsa_auth 程序而不是旧的 ncsa_auth
鱿鱼 2.x
对于 squid 2.x,您需要编辑 /etc/squid/squid.conf
文件并放置:
auth_param basic program /usr/lib/squid/digest_pw_auth /etc/squid/passwords
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
设置用户
sudo htpasswd -c /etc/squid3/passwords username_you_like
然后为所选用户名输入两次密码
sudo service squid3 restart
鱿鱼 2.x
sudo htpasswd -c /etc/squid/passwords username_you_like
然后为所选用户名输入两次密码
sudo service squid restart
htdigest 与 htpasswd
对于许多问我的人:这两种工具产生不同的文件格式:
htdigest 以纯文本形式存储密码。
htpasswd 存储密码哈希(各种哈希算法可用)
尽管 basic_ncsa_auth
格式存在这种差异,仍然能够解析使用 htdigest
生成的密码文件。因此,您可以选择使用:
sudo htdigest -c /etc/squid3/passwords realm_you_like username_you_like
请注意,这种方法是经验性的、未记录的,未来版本的 Squid 可能不支持。
在 Ubuntu 14.04 上,htdigest
和 htpasswd
都在 [apache2-utils][1]
包中可用。
苹果系统
与上述类似,但文件路径不同。
安装鱿鱼
brew install squid
启动鱿鱼服务
brew services start squid
Squid 配置文件存储在 /usr/local/etc/squid.conf
。
评论或删除以下行:
http_access allow localnet
然后类似于 linux 配置(但具有更新的路径)添加:
auth_param basic program /usr/local/Cellar/squid/4.8/libexec/basic_ncsa_auth /usr/local/etc/squid_passwords
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
请注意,到 basic_ncsa_auth
的路径可能不同,因为它取决于使用 brew
时安装的版本,您可以使用 ls /usr/local/Cellar/squid/
验证这一点。另请注意,您应该在以下部分添加上述内容:
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
现在为自己生成一个 user:password 基本身份验证凭据(注意:htpasswd
和 htdigest
在 MacOS 上也可用)
htpasswd -c /usr/local/etc/squid_passwords username_you_like
重启squid服务
brew services restart squid
不定期副业成功案例分享
htpasswd
,请执行sudo apt-get install apache2-utils
。