squid代理使用yum源

原文地址:https://www.cnblogs.com/effortsing/p/10060821.html

参考地址:https://blog.csdn.net/J080624/article/details/53728535

 

 

环境: 内网中的服务器只有一台(bcec001)可以连外网(可以使用公网yum源),其他服务器(bcec002)无法连外网。操作系统Centos7.4

安全组都打开3128端口

公网地址:114.115.178.26 私有地址:10.1.1.3

另一台服务器内网地址:10.1.1.5

 

服务端配置:

[root@host-10-1-1-161 ~]# systemctl stop firewalld

在114.115.178.26安装 Squid.

[root@host-10-1-1-161 ~]# yum install squid -y


配置squid

[root@host-10-1-1-161 ~]#vi /etc/squid/squid.conf

删除原有内容,添加如下内容,

cache_mem 64 MB
maximum_object_size 4 MB
cache_dir ufs /var/spool/squid 100 16 256
access_log /var/log/squid/access.log
http_access allow all
visible_hostname ecs-01.novalocal #squid那台主机名

squid -k parse # 配置文件解析日志中,没有出现ERROR 就没有问题

初始化

[root@host-10-1-1-161 ~]# squid -z
什么都没显示,说明初始化成功。 注意:会出现一屏字符,不影响 银盾云主机显示一行文字,不影响

启动Squid

[root@host-10-1-1-161 ~]#/etc/init.d/squid start

 

客户端配置:

4、在其它想使用此代理的主机上配置yum的代理

vi /etc/yum.conf加入以下内容:proxy=http://10.1.1.3:3128

vi /etc/wgetrc 加入以下内容:http_proxy=http://10.1.1.3:3128

vim /etc/profile

#查找并修改或追加以下语句(将10.0.0.1修改为你的Squid配置的监听地址或服务器的IP):
export http_proxy=http://10.0.0.3:3128/
export ftp_proxy=http://10.0.0.3:3128/

export https_proxy=http://10.0.0.3:3128/

 

[root@host-10-1-1-111 ~]# sed -i '$a\proxy=http://10.1.1.3:3128' /etc/yum.conf
[root@host-10-1-1-111 ~]# sed -i '$a\proxy=http://10.1.1.3:3128' /etc/wgetrc
[root@host-10-1-1-111 ~]# sed -i '$a\proxy=http://10.1.1.3:3128' /etc/profile
[root@host-10-1-1-111 ~]# sed -i '$a\ftp=http://10.1.1.3:3128' /etc/profile
[root@host-10-1-1-111 ~]# source /etc/profile
[root@host-10-1-1-111 ~]# source /etc/profile
注意:对于华为云要 source 两次


5、客户端、服务端的防火墙打开端口,实在不行就直接关掉防火墙,

[root@ecs-b8b7 ~]# firewall-cmd --add-port=3128/tcp -- permanent
[root@ecs-b8b7 ~]# systemctl stop firewalld



posted @ 2022-06-27 11:27  奋斗!奋斗!  阅读(326)  评论(0编辑  收藏  举报