我目前在acl中使用ip,我想使用用户名和密码来完成此操作。
发布于 2014-07-22 10:22:21
下面是我在Ubuntu14.04上设置基本身份验证的步骤(在其他地方找不到指南)
基本squid配置
/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
squid 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
squid 2.x
sudo htpasswd -c /etc/squid/passwords username_you_like
并为所选用户名输入两次密码,然后
sudo service squid restart
htdigest与htpasswd
对于许多人问我:这两个工具产生不同的文件格式:
htdigest
以明文形式存储密码text.htpasswd
存储经过哈希处理的密码(提供各种哈希算法)尽管格式不同,basic_ncsa_auth
仍然能够解析使用 htdigest
.生成的密码文件因此,您可以选择使用:
sudo htdigest -c /etc/squid3/passwords realm_you_like username_you_like
请注意,此方法是经验性的,未记录在案,可能不受Squid未来版本的支持。
在Ubuntu14.04上,htdigest
和htpasswd
都可以在[apache2-utils][1]
包中获得。
MacOS
类似于上面的应用,但文件路径不同。
安装squid
brew install squid
启动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
请注意,在使用brew
时,basic_ncsa_auth
的路径可能不同,因为它取决于安装的版本,您可以使用ls /usr/local/Cellar/squid/
验证这一点。另请注意,您应该在以下部分下面添加上面的内容:
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
现在为自己生成一个user:password basic auth凭据(注意:MacOS上也提供了htpasswd
和htdigest
)
htpasswd -c /usr/local/etc/squid_passwords username_you_like
重新启动squid服务
brew services restart squid
https://stackoverflow.com/questions/3297196
复制相似问题