baker95935

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

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

 

posted on 2018-05-24 10:43  baker95935  阅读(360)  评论(0编辑  收藏  举报