2 Star 1 Fork 0

zhrun8899 / learning-notes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
squid 代理上网.md 1.58 KB
一键复制 编辑 原始数据 按行查看 历史

squid 代理上网

服务端配置:

yum install squid

yum install squid -y

yum install httpd-tools -y

htpasswd -cd /etc/squid3/passwords webimation
elink@D18
## 执行的结果是/etc/squid3/passowrds中有一条记录:webimation:nbFWKvfI/pP7U

vim /etc/squid/squid.conf

#在最后添加
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated

#这里是端口号,可以按需修改
#http_port 3128 这样写会同时监听ipv6和ipv4的端口,推荐适应下面的配置方法。
http_port 0.0.0.0:3128

启动squid服务

systemctl start squid.service

防火墙如果启动需要增加 3128的访问

firewall-cmd --add-port=3128/tcp --permanent

systemctl restart firewalld

客户端配置:

http代理:

## \\192.168.9.111是代理服务器ip
export http_proxy=http://192.168.9.111:3128        
export https_proxy=http://192.168.9.111:3128

yum使用代理上网:

/etc/yum.conf 最后加一句话:

proxy=http://webimation:elinkD18@192.168.9.111:3128/

实现:在管理中心使用ansible脚本

[root@saltMaster ~]# vim /etc/ansible/addProxy.sh

sed -i '/^export https_proxy/d' /etc/yum.conf
sed -i '$a proxy=http://webimation:elinkD18@192.168.9.4:3128/ ' /etc/yum.conf
sed -i '$a export http_proxy=http://192.168.9.4:3128/ ' /etc/profile
sed -i '$a export https_proxy=http://192.168.9.4:3128/ ' /etc/profile
source /etc/profile

执行脚本

chmod +x addProxy.sh
ansible web -m script  -a  "/root/software/addProxy.sh"
1
https://gitee.com/zhrun8899/learning-notes.git
git@gitee.com:zhrun8899/learning-notes.git
zhrun8899
learning-notes
learning-notes
master

搜索帮助