利用nginx 来实现内网yum源(反向代理)
简介
在项目部署时,尤其是在政府企业,对于外网简直是奢望,但是对于运维来说,没有外网的话只能自建yum源。我今天来说的是一种简单的自建yum源方法,前提是必须有一台内外网都有的机器,我们一般称为前置机。
操作思路
1、使用nginx 反向代理 阿里云源
2、在内网机器自建repo指向nginxip
nginx配置
12345678 | server { listen 80; location /centos/ { proxy_pass http://mirrors.aliyun.com/centos/ ; }} |
比较简单,不过我们要求不高能用即可。
另外我们常用的linux系统是Centos,所以我这边只写了Centos的。其它的你也可以参考上面配置配置。
内网机器配置
1、备份CentOS-Base.repo
1 | # mv CentOS-Base.repo CentOS-Base.repo.bak |
2、增加反向代理的repo
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | vim /etc/yum.repos.d/Centos-7.repo[base]name=CentOS-$releasever - Base - 10.12.64.130failovermethod=prioritybaseurl=http://10.12.64.130/centos/$releasever/os/$basearch/http://10.12.64.130/centos/$releasever/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osgpgcheck=1gpgkey=http://10.12.64.130/centos/RPM-GPG-KEY-CentOS-7#released updates [updates]name=CentOS-$releasever - Updates - 10.12.64.130failovermethod=prioritybaseurl=http://10.12.64.130/centos/$releasever/updates/$basearch/http://10.12.64.130/centos/$releasever/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesgpgcheck=1gpgkey=http://10.12.64.130/centos/RPM-GPG-KEY-CentOS-7#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - 10.12.64.130failovermethod=prioritybaseurl=http://10.12.64.130/centos/$releasever/extras/$basearch/http://10.12.64.130/centos/$releasever/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasgpgcheck=1gpgkey=http://10.12.64.130/centos/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - 10.12.64.130failovermethod=prioritybaseurl=http://10.12.64.130/centos/$releasever/centosplus/$basearch/http://10.12.64.130/centos/$releasever/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=http://10.12.64.130/centos/RPM-GPG-KEY-CentOS-7#contrib - packages by Centos Users[contrib]name=CentOS-$releasever - Contrib - 10.12.64.130failovermethod=prioritybaseurl=http://10.12.64.130/centos/$releasever/contrib/$basearch/http://10.12.64.130/centos/$releasever/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contribgpgcheck=1enabled=0gpgkey=http://10.12.64.130/centos/RPM-GPG-KEY-CentOS-7 |
注:其中的10.12.64.130为我的前置机ip地址,大家可以更具情况自行修改。
测试
12 | # yum makecache |
在随机安装一个net-tools 测试即可
以上
End
相关推荐
ssihc0 2020-11-11
scaleqiao 2020-10-22
tinydu 2020-08-03
ysmh00 2020-07-04
SZStudy 2020-07-04
TiDBPingCAP 2020-06-28
sicceer 2020-06-21
ssihc0 2020-06-14
WasteLand 2020-06-13
咏月东南 2020-06-10
某些公司会墙特定网站,如果你有一个可访问的域名和服务器,就可以通过nginx反向代理来来解决这些问题。比如现在我们用mirror.example.com镜像www.baidu.com,以下是详细操作。
byourb 2020-06-05
阳光岛主 2020-06-01
hyxinyu 2020-04-27
yungame 2020-04-25
咻咻ing 2020-04-19
OwenJi 2020-04-18