实战记录——Centos使用squid搭建带用户认证的高匿HTTP代理服务

阅读: 评论:0

实战记录——Centos使用squid搭建带用户认证的高匿HTTP代理服务

实战记录——Centos使用squid搭建带用户认证的高匿HTTP代理服务

1.安装相关包

带用户认证需要用到httpd-tool

yum install -y squid httpd-tool

2.生成密码文件

使用 htpasswd 命令生成密码文件,默认是MD5的格式,可以用选项改其他格式

命令格式:
htpasswd [选项] 文件名 用户名

常用选项
-c 创建新文件,如果没加此选项会把新增的用户添加在末尾
-2 SHA-256格式的密码
-5 SHA-512格式的密码
-B bcrypt格式的密码
-d CRYPT格式的密码
-s SHA-1格式的密码

示例:

htpasswd /etc/squid/passwd test

3.配置squid

打开配置文件

vim /etc/f***注意:先把其他http_access注释掉,很重要***用户认证添加以下配置,
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd #用户验证使用模块
auth_param basic children 5	#可同时验证数量
auth_param basic realm test #连接提示文本
auth_param basic credentialsttl 1 days #认证有效期,这里也可以改成小时
acl users proxy_auth REQUIRED #用户认证
http_access allow users #通过认证的允许访问
http_access deny all #默认拒绝其中basic_ncsa_auth模块不一定同位置可以自己查看位置在哪
rpm -ql squid |grep ncsa高匿添加配置
request_header_access Via deny all
request_header_access X-Forwarded-For deny all可选关闭缓存和隐藏缓存请求头
acl denyssl method GET
no_cache deny denysslrequest_header_access Server deny all
request_header_access X-Cache deny all
request_header_access X-Cache-Lookup deny all开放端口
http_port 3128 #3128是默认记得修改

测试时使用的配置文件


acl localnet src 0.0.0.1-0.255.255.255acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
acl Safe_ports port 70		# gopher
acl Safe_ports port 210		# wais
acl Safe_ports port 1025-65535	# unregistered ports
acl Safe_ports port 280		# http-mgmt
acl Safe_ports port 488		# gss-http
acl Safe_ports port 591		# filemaker
acl Safe_ports port 777		# multiling http
acl CONNECT method CONNECTaccess_log /var/log/squid/access.log
acl denyssl method GET
no_cache deny denysslauth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm test
auth_param basic credentialsttl 1 days
acl users proxy_auth REQUIRED
http_access allow users
http_access deny allrequest_header_access Via deny all
request_header_access X-Forwarded-For deny all
request_header_access Server deny all
request_header_access X-Cache deny all
request_header_access X-Cache-Lookup deny allhttp_port 23128coredump_dir /var/spool/squidrefresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern -i (/cgi-bin/|?) 0	0%	0
refresh_pattern .		0	20%	4320

使用命令检查配置,没问题启动即可
squid -k parse
systemctl start squid

关闭时建议使用
squid -k shutdown

本文发布于:2024-01-29 10:35:06,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170649570914672.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:实战   代理服务   用户   squid   Centos
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23