码迷,mamicode.com
首页 > 其他好文 > 详细

利用nginx 来实现内网yum源(反向代理)

时间:2020-04-15 18:43:23      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:部署   list   class   利用   body   常用   操作   它的   add   

简介

在项目部署时,尤其是在政府企业,对于外网简直是奢望,但是对于运维来说,没有外网的话只能自建yum源。我今天来说的是一种简单的自建yum源方法,前提是必须有一台内外网都有的机器,我们一般称为前置机。

操作思路

1、使用nginx 反向代理 阿里云源

2、在内网机器自建repo指向nginxip

nginx配置

1
2
3
4
5
6
7
8
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
vim /etc/yum.repos.d/Centos-7.repo
[base]
name=CentOS-$releasever - Base - 10.12.64.130
failovermethod=priority
baseurl=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=os
gpgcheck=1
gpgkey=http://10.12.64.130/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - 10.12.64.130
failovermethod=priority
baseurl=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=updates
gpgcheck=1
gpgkey=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.130
failovermethod=priority
baseurl=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=extras
gpgcheck=1
gpgkey=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.130
failovermethod=priority
baseurl=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=centosplus
gpgcheck=1
enabled=0
gpgkey=http://10.12.64.130/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 10.12.64.130
failovermethod=priority
baseurl=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=contrib
gpgcheck=1
enabled=0
gpgkey=http://10.12.64.130/centos/RPM-GPG-KEY-CentOS-7

注:其中的10.12.64.130为我的前置机ip地址,大家可以更具情况自行修改。

测试

1
2

# yum makecache

在随机安装一个net-tools 测试即可

以上

End

利用nginx 来实现内网yum源(反向代理)

标签:部署   list   class   利用   body   常用   操作   它的   add   

原文地址:https://www.cnblogs.com/keystone/p/12706659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!