1.安装
sudo yum install squid
2.备份
sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.bak
3.设置用户和组
sudo touch /etc/squid/passwords
sudo chown squid:squid /etc/squid/passwords
sudo chmod 400 /etc/squid/passwords
4.安装 htpasswd
sudo yum install httpd-tools
sudo htpasswd -c /etc/squid/passwords username #username 替换
输入密码 password
5.编辑配置文件,增加内容 /etc/squid/squid.conf
# 开启基本身份验证
# auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords # 是否是 64位
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
# 设置访问控制规则,允许特定用户访问代理
acl authenticated_users proxy_auth REQUIRED
http_access allow authenticated_users
6.重启代理
sudo systemctl restart squid
标签:sudo,centos,squid,auth,etc,passwords,basic,搭建 From: https://www.cnblogs.com/hui413027075/p/18227753