阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

使用Nginx制作内网yum镜像代理

166次阅读
没有评论

共计 5179 个字符,预计需要花费 13 分钟才能阅读完成。

使用 Nginx 制作内网 yum 镜像代理

  • 使用 Nginx 制作内网 yum 镜像代理

    • 1. 背景

    • 2. 环境需求

    • 3. Nginx 安装配置

1. 背景

公司内网服务器不能直接通过 Internet 上网,但为了与外网通信和同步时间等,会指定那么几台服务器可以访问 Internet。这里就是通过能上网的机器作为代理,制作内网使用的 yum 仓库。

2. 环境需求

  1. 内网 dns(推荐,非必须,因为可使用 IP 代替)

  2. 一台能上 Internet 的服务器 A

  3. 不能上 Internet 的服务器能与 A 服务器通信

  4. 这里示例为 CentOS7 和 Ubuntu16

3. Nginx 安装配置

Nginx 安装在能上网的 A 服务器上,安装过程略。
具体一个 nginx server 配置如下:

# mirrors
server
   {
       listen 80;
       #listen [::]:80;
       server_name mirrors.yourdomain.com;
       index index.html index.htm index.php default.html default.htm default.php;
       root  /home/wwwroot/html;

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

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

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

以上使用阿里云镜像,其镜像版本很全,速度也很快。
http://mirrors.aliyun.com/

CentOS7 系统镜像源:
cat /etc/yum.repos.d/CentOS-7.repo

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

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

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

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.yourdomain.com
failovermethod=priority
baseurl=http://mirrors.yourdomain.com/centos/$releasever/centosplus/$basearch/
       http://mirrors.yourdomain.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.yourdomain.com
failovermethod=priority
baseurl=http://mirrors.yourdomain.com/centos/$releasever/contrib/$basearch/
       http://mirrors.yourdomain.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7

EPEL 第三方扩展源:
cat /etc/yum.repos.d/epel.repo

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.yourdomain.com/epel/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]

name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://download.yourdomain.com/epel/7/$basearch/debug
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]

name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://download.yourdomain.com/epel/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

Ubuntu16 apt 镜像源:
cat /etc/apt/sources.list

deb http://mirrors.yourdomain.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.yourdomain.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.yourdomain.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.yourdomain.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.yourdomain.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.yourdomain.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.yourdomain.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.yourdomain.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.yourdomain.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.yourdomain.com/ubuntu/ xenial-backports main restricted universe multiverse

更多 YUM 相关教程见以下内容

RHEL7 本地 yum 源配置 http://www.linuxidc.com/Linux/2017-01/139140.htm

CentOS 6.5 配置本地 Yum 源  http://www.linuxidc.com/Linux/2017-04/143127.htm

CentOS 7 使用阿里云的 yum 源、PIP 源 http://www.linuxidc.com/Linux/2017-01/13966.htm

CentOS 及 Red Hat Linux 安装 yum 源  http://www.linuxidc.com/Linux/2017-02/140205.htm

CentOS 7 更改 yum 源与更新系统 http://www.linuxidc.com/Linux/2017-01/140067.htm

RedHat7.0 配置本地 yum 源  http://www.linuxidc.com/Linux/2017-01/139148.htm 

RedHat Linux 7 安装 CentOS 7 yum 源  http://www.linuxidc.com/Linux/2017-04/142444.htm

软件包管理之前端管理工具 yum  http://www.linuxidc.com/Linux/2017-02/140270.htm

CentOS 7 使用阿里云的 yum 源、PIP 源 http://www.linuxidc.com/Linux/2017-01/13966.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-08/146598.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计5179字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中