1、安装squid、http(安装过squid就直接安装httpd)
yum install -y squid httpd
2、配置NCSA认证
①创建认证用户名密码,使用Http的htpasswd
注意,san为用户名!!!按回车后输入两次密码确认
htpasswd -c /etc/squid/passwd san
②确定squid是否支持authentication helper
rpm -ql squid | grep ncsa_auth
输出
/usr/lib64/squid/basic_ncsa_auth
③配置squid.conf
vim /etc/squid/squid.conf
# 设置的端口 http_port 3333 # 第命令输出的地址 定义squid密码文件与ncsa_auth文件位置 auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd #认证进程的数量 auth_param basic children 100 #认证有效期 auth_param basic credentialsttl 2 hours #用户名不区分大小写,可改为ON区分大小写 auth_param basic casesensitive off #在acl行适当位置增加 acl qunar proxy_auth REQUIRED #1命令设置的用户名 http_access allow san #http_access allow all # 配置高匿,不允许设置任何多余头信息,保持原请求header。 header_access Via deny all header_access X-Forwarded-For deny all header_access Server deny all header_access X-Cache deny all header_access X-Cache-Lookup deny all #此行加在配置文件末尾即可 #access log time human-readable logformat squid %tl.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %un %Sh/%<A %mt
④重启squid
centos7
# 启动
systemctl start squid.service
# 停止
systemctl stop squid.service
# 重启
systemctl restart squid.service
centos6
service squid start
service squid stop
service squid restart
本文由 SAn 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:
2020/05/14 21:52