配置阿里yum源代理访问

该博客介绍了如何在内网环境中,通过配置Nginx作为代理服务器,使客户端能够访问外网的Yum源。首先,Nginx服务器配置了多个location,分别代理了阿里云和 ustc 的CentOS、EPEL和MariaDB镜像。然后,客户端的Yum源配置文件中,指定了内网地址作为基础、更新、额外和Plus仓库的URL,并清除了yum缓存。最后,通过`yum list`命令测试了配置是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境:网关服务器可以上网、客户端为内网,不允许上网

服务端配置nginx代理

server{
       listen 16666;
       server_name _;
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers X-Requested-With;
        add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

        location / {
            root   html;
            index  index.html index.htm;
        }

        location /centos/ {
            proxy_pass http://mirrors.aliyun.com/centos/;
        }

        location /epel/ {
            proxy_pass http://mirrors.aliyun.com/epel/;
        }

        location /mariadb/ {
            proxy_pass http://mirrors.ustc.edu.cn/mariadb/;
        }

    }

使用yum源的客户端配置

[root@master1 ~]# cd /etc/yum.repos.d/
[root@master1 yum.repos.d]# vim CentOS-Base.repo 
[base]
name=CentOS-$releasever - Base - 192.168.100.100:16666
failovermethod=priority
baseurl=http://192.168.100.100:16666/centos/$releasever/os/$basearch/
        http://192.168.100.100:16666/centos/$releasever/os/$basearch/
#        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://192.168.100.100:16666/centos/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates - 192.168.100.100:16666
failovermethod=priority
baseurl=http://192.168.100.100:16666/centos/$releasever/updates/$basearch/
        http://192.168.100.100:16666/centos/$releasever/updates/$basearch/
#        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://192.168.100.100:16666/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 192.168.100.100:16666
failovermethod=priority
baseurl=http://192.168.100.100:16666/centos/$releasever/extras/$basearch/
        http://192.168.100.100:16666/centos/$releasever/extras/$basearch/
#        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://192.168.100.100:16666/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 192.168.100.100:16666
failovermethod=priority
baseurl=http://192.168.100.100:16666/centos/$releasever/centosplus/$basearch/
        http://192.168.100.100:16666/centos/$releasever/centosplus/$basearch/
#        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://192.168.100.100:16666/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 192.168.100.100:16666
failovermethod=priority
baseurl=http://192.168.100.100:16666/centos/$releasever/contrib/$basearch/
        http://192.168.100.100:16666/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://192.168.100.100:16666/centos/RPM-GPG-KEY-CentOS-7

清理yum缓存

yum clean all

测试

yum list
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值