yum install squid -y
yum install httpd-tools -y
mkdir /etc/squid3/
#wuloves 是用户名
htpasswd -cd /etc/squid3/passwords wuloves
#提示输入密码,比如输入12345678, 这边限制密码长度必须为8位数
test 12345678
/usr/lib64/squid/basic_ncsa_auth /etc/squid3/passwords
#输入用户名 密码
test 12345678
#提示ok说明成功
ok
#ctrl+c退出
vi /etc/squid/squid.conf
#在最前面添加,如果密码认证放在 http_access allow all 后面,会有可能导致密码不鉴权了
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid3/passwords
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
# And finally deny all other access to this proxy
http_access allow all
#这里是端口号,可以按需修改
#http_port 3128 这样写会同时监听ipv6和ipv4的端口,推荐适应下面的配置方法。
http_port 0.0.0.0:3128
#启动start
systemctl start squid.service
#停止stop
systemctl stop squid.service
#重启stop
systemctl restart squid.service
#配置开机自启动
systemctl enable squid.service
#关闭开机自启动
systemctl disable squid.service
#查看运行状态
systemctl status squid.service
firewall-cmd --permanent --zone=public --add-port=444/tcp
systemctl restart firewalld.service
测试
curl -x test:12345678@192.168.3.6:3128 https://www.wuloves.com
下面是配置方式2
yum install squid
systemctl restart squid.service
systemctl enable squid.service
编辑配置文件, 在开头处增加即可
vim /etc/squid/squid.conf
acl localnet src 0.0.0.0/0
# http_port 3128 >>> http_port 3129
重启服务即可
默认代理端口 3128
遇到问题
Google不能访问,github正常,在对应的主机上访问Google正常
是因为代理被大陆网关给拦截了
tracteroute路由追踪正常
代理使用增加鉴权
- htpasswd生成passwd文件并创建用户
squiduser
htpasswd -c /etc/squid/passwd squiduser
如果命令不能使用, 执行
yum install httpd
- 在
/etc/squid/squid.conf
增加内容
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
acl auth_user proxy_auth REQUIRED
http_access allow auth_user
- 重启squid
#systemctl restart squid