centos7.3给squid搭建代理服务器添加认证nginx

1先安装 nginx

这里是教程 点击查看

2 然后 使用命令 创建用户

htpasswd -c /etc/nginx/passwd.db baker

输入密码  提示添加完毕

3 查看加密后的用户和密码

cat passwd.db

4 nginx中配置auth_basic 和auth_basic_user_file

在nginx的配置文件总  nginx.conf

localtion / {} 里面加入

auth_basic "your name and your password"; //这个是提示语
auth_basic_user_file /etc/nginx/passwd.db;//这个是认证文件

5 修改squid.conf

auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/nginx/passwd.db
auth_param basic credentialsttl 5 hours
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users

并且把 其他allow all 的给注释掉

注释其他代码

#http_access allow localnet
#http_access allow all

6 nginx和squid重启

service nginx restart
service squid restart

7 打开浏览器测试

弹窗 输入用户名和密码的提示框 

输入步骤1里面的 用户名和密码 即可完成校验  使用代理服务

8 如果想添加其他用户 使用htpasswd命令即可 不用重启squid服务,实时生效的

htpasswd -c /etc/nginx/passwd.db test

猜你喜欢

转载自www.cnblogs.com/baker95935/p/9081578.html
今日推荐