1. Application scenario:
In some application scenarios, Linux servers need to install application packages through yum, but these Linux servers may not be able to connect to the external network, but there is no corresponding Yum server inside. At this time, find a server that can access the external network inside to configure a proxy, and then use the proxy to perform the yum action.
2. Configure the squid agent on the machine that can be connected to the Internet:
[root@test_20190130_wanl01 ~]# yum -y install openssl squid [root@test_20190130_wanl01 ~]# vim /etc/squid/squid.conf # And finally deny all other access to this proxy # http_access deny all http_access allow all [root@test_20190130_wanl01 ~]# systemctl start squid [root@test_20190130_wanl01 ~]# systemctl enable squid Created symlink from /etc/systemd/system/multi-user.target.wants/squid.service to /usr/lib/systemd/system/squid.service. [root@test_20190130_wanl01 ~]# systemctl status squid ● squid.service - Squid caching proxy Loaded: loaded (/usr/lib/systemd/system/squid.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2019-04-29 22:01:31 CST; 14s ago Main PID: 16818 (squid) CGroup: /system.slice/squid.service ├─16818 /usr/sbin/squid -f /etc/squid/squid.conf ├─16820 (squid-1) -f /etc/squid/squid.conf └─16821 (logfile-daemon) /var/log/squid/access.log Apr 29 22:01:31 test_20190130_wanl01 systemd[1]: Starting Squid caching proxy... Apr 29 22:01:31 test_20190130_wanl01 systemd[1]: Started Squid caching proxy. Apr 29 22:01:32 test_20190130_wanl01 squid[16818]: Squid Parent: will start 1 kids Apr 29 22:01:32 test_20190130_wanl01 squid[16818]: Squid Parent: (squid-1) process 16820 started [root@test_20190130_wanl01 ~]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 2129/mongod tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 25748/nginx: master tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN 25708/httpd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2291/sshd tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN 1275/java tcp6 0 0 :::80 :::* LISTEN 25748/nginx: master tcp6 0 0 :::3128 :::* LISTEN 16820/(squid-1) #Description: port 3128 is open, indicating that the agent is normal
3. Configure yum proxy for client server
First of all, you need to edit the repo file in the client of yum, because it will be used when installing related packages. Here, please refer to https://www.cnblogs.com/jimboi/p/8437788.html
[root@iZvy2dcjg9cbw404qmksfhZ ~]# vim /etc/yum.conf #Add the following information proxy=http://27.0.1.90:3128 [root@iZvy2dcjg9cbw404qmksfhZ ~]# ping www.baidu.com ping: www.baidu.com: Name or service not known [root@iZvy2dcjg9cbw404qmksfhZ yum.repos.d]# yum -y install squid Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/7): base/7/x86_64/group_gz | 166 kB 00:00:00 (2/7): epel/x86_64/group_gz | 88 kB 00:00:00 (3/7): extras/7/x86_64/primary_db | 188 kB 00:00:00 (4/7): epel/x86_64/updateinfo | 991 kB 00:00:00 (5/7): epel/x86_64/primary_db | 6.7 MB 00:00:00 (6/7): updates/7/x86_64/primary_db | 3.4 MB 00:00:00 (7/7): base/7/x86_64/primary_db | 6.0 MB 00:00:01 Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies