密码控制
非固定IP的情况使用的方法
https://www.yfname.com/help/detail/288
Squid认证(未试验)¶
如果基于IP的访问限制对你的使用情况不起作用,你可以配置squid使用后端来验证用户。Squid支持Samba、LDAP和HTTP基本认证。
在本指南中,我们将使用basic auth。它是HTTP协议中内置的一种简单认证方法。
要生成一个加密的密码,请使用openssl工具。下面的命令将USERNAME:PASSWORD对附加到/etc/squid/htpasswd文件中。
例如,要创建一个密码为 "P@ssvv0rT "的用户 "josh",你需要运行。
Text Only
$ printf "josh:$(openssl passwd -crypt 'P@ssvv0rd')\n" | sudo tee -a /etc/squid/htpasswd
josh:QMxVjdyPchJl6
下一步是启用HTTP基本认证,并将包含用户凭证的文件纳入squid配置文件。
打开主配置,添加以下内容。
/etc/squid/squid.conf
Bash
# ...
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/htpasswd
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
# ...
#http_access allow localnet
http_access allow localhost
http_access allow authenticated
# And finally deny all other access to this proxy
http_access deny all
前三行是创建一个新的ACL,名为authenticated,最后一行是允许认证用户访问的。
重新启动Squid服务。