ubuntu20配nginx代理yum源,内网不能上网

时间:2022-11-06 19:59:24

1、yum-server

# yum-server 外网IP 1.1.1.1

root@yum-ser:/etc/nginx/sites-available# cat default

server {

listen 80 default_server;

server_name 1.1.1.1;

client_max_body_size 1024M;

location /centos/ {

proxy_pass http://mirrors.aliyun.com/centos/ ;

}

}


2、yum-client 验证

root@yum-ser:/etc/nginx/sites-available# cat /root/CentOS7-1.1.1.1.repo

[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://1.1.1.1/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://1.1.1.1/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://1.1.1.1/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://1.1.1.1/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://1.1.1.1/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://1.1.1.1/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://1.1.1.1/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://1.1.1.1/centos/RPM-GPG-KEY-CentOS-7

3、验证

报错超时

[root@yum-client ~]# yum clean all;yum makecache
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror
Determining fastest mirrors
http://1.1.1.1/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://20.135.1.200/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
http://1.1.1.1/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://20.135.1.200/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.

4、处理

root@yum-ser:~# service nginx reload

root@yum-ser:~# nginx -s reload

5、再验证

[root@yum-client yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: 1.1.1.1
* extras: 1.1.1.1
* updates: 1.1.1.1
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/10): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/10): base/7/x86_64/primary_db | 6.1 MB 00:00:04
(3/10): extras/7/x86_64/primary_db | 249 kB 00:00:00
(4/10): extras/7/x86_64/filelists_db | 276 kB 00:00:00
(5/10): extras/7/x86_64/other_db | 149 kB 00:00:00
(6/10): base/7/x86_64/filelists_db | 7.2 MB 00:00:05
(7/10): base/7/x86_64/other_db | 2.6 MB 00:00:02
(8/10): updates/7/x86_64/primary_db | 17 MB 00:00:06
(9/10): updates/7/x86_64/other_db | 1.2 MB 00:00:01
(10/10): updates/7/x86_64/filelists_db | 9.6 MB 00:00:09
Metadata Cache Created

[root@yum-client yum.repos.d]# yum install -y tmux
Loaded plugins: fastestmirror
................