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

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

1. 背景

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

2. 环境需求

  1. 内网dns(推荐,非必须,因为可使用IP代替)
  2. 一台能上Internet的服务器A
  3. 不能上Internet的服务器能与A服务器通信
  4. 这里示例为CentOS7和Ubuntu16

3. Nginx安装配置

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

# mirrorsserver    {        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.comfailovermethod=prioritybaseurl=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=osgpgcheck=1gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7

#released updates [updates]name=CentOS-$releasever - Updates - mirrors.yourdomain.comfailovermethod=prioritybaseurl=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=updatesgpgcheck=1gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - mirrors.yourdomain.comfailovermethod=prioritybaseurl=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=extrasgpgcheck=1gpgkey=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.comfailovermethod=prioritybaseurl=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=centosplusgpgcheck=1enabled=0gpgkey=http://mirrors.yourdomain.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users[contrib]name=CentOS-$releasever - Contrib - mirrors.yourdomain.comfailovermethod=prioritybaseurl=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=contribgpgcheck=1enabled=0gpgkey=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 - $basearchbaseurl=http://mirrors.yourdomain.com/epel/7/$basearchfailovermethod=priorityenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]name=Extra Packages for Enterprise Linux 7 - $basearch - Debugbaseurl=http://download.yourdomain.com/epel/7/$basearch/debugfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=1

[epel-source]name=Extra Packages for Enterprise Linux 7 - $basearch - Sourcebaseurl=http://download.yourdomain.com/epel/7/SRPMSfailovermethod=priorityenabled=0gpgkey=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 multiversedeb http://mirrors.yourdomain.com/ubuntu/ xenial-security main restricted universe multiversedeb http://mirrors.yourdomain.com/ubuntu/ xenial-updates main restricted universe multiversedeb http://mirrors.yourdomain.com/ubuntu/ xenial-proposed main restricted universe multiversedeb http://mirrors.yourdomain.com/ubuntu/ xenial-backports main restricted universe multiversedeb-src http://mirrors.yourdomain.com/ubuntu/ xenial main restricted universe multiversedeb-src http://mirrors.yourdomain.com/ubuntu/ xenial-security main restricted universe multiversedeb-src http://mirrors.yourdomain.com/ubuntu/ xenial-updates main restricted universe multiversedeb-src http://mirrors.yourdomain.com/ubuntu/ xenial-proposed main restricted universe multiversedeb-src http://mirrors.yourdomain.com/ubuntu/ xenial-backports main restricted universe multiverse
时间: 2024-08-11 05:46:02

使用Nginx制作内网yum镜像代理的相关文章

制作内网yum源 同步阿里的源

本文参考:http://www.studylinux.net/?p=4515 操作系统centos7(selinux  firewalld关闭 ) 安装cobbler命令修改为阿里的yum源  163的也可以 wget -O /etc/yum.repos.d/CentOS-Base.repo  wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 3.安装cobbler命令 最好都安装上 yum

搭建内网yum仓库

编译源码,根据自己的需求做成定制RPM包–>搭建内网yum仓库–yum安装. [root@www ~]# uname -aLinux www 2.6.32-642.6.2.el6.x86_64 #1 SMP Wed Oct 26 06:52:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux [root@www ~]# cat /etc/redhat-release CentOS release 6.8 (Final) =================定制化R

RadHat搭建内网YUM源服务器

前言:随着内网linux服务器越来越多,在每台服务器上安装软件,都要先把安装盘上传上去,在配置本地yum服务,即麻烦又费时.可以在内网的一台linux服务器上安装yum服务,然后其他服务器直接修改repo文件使用yum服务就可以了.安装步骤如下: Linux系统环境 1.RHEL版本 [[email protected] pub]# cat /etc/issue Red Hat Enterprise Linux Server release 6.5 (Santiago) 2.内核版本 [[ema

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

简介 在项目部署时,尤其是在政府企业,对于外网简直是奢望,但是对于运维来说,没有外网的话只能自建yum源.我今天来说的是一种简单的自建yum源方法,前提是必须有一台内外网都有的机器,我们一般称为前置机. 操作思路 1.使用nginx 反向代理 阿里云源 2.在内网机器自建repo指向nginxip nginx配置 12345678 server { listen 80; location /centos/ { proxy_pass http://mirrors.aliyun.com/centos

搭建基于HTTP协议内网yum仓库

目录 1. 前言 2. 把rpm包下载到本地 3. 配置nginx对外提供服务 4. 配置本地repo文件 5. 生成repodata信息 6. 检查及使用 7. 对管理机器上的仓库进行更新 参考资料 环境:VMware-Workstation-12-Pro,Windows-10,CentOS-7.5,Xshell5 1. 前言 如果我们的yum仓库需要多台机器共同使用,此时把yum仓库做成本地的,然后一台台scp推送过去比较麻烦,此时可以考虑搭建一个基于HTTP协议,供给内网其它机器使用的本地

windows系统下hosts文件的改写(为了测试nginx内网的证书代理,需要做域名解析)

1. win加R     C:\WINDOWS\system32\drivers\etc 2.打开hosts文件  加入一行  IP为客户机要访问的IP地址  域名也是在nginx中定义好的 3.ctrl+s 保存,需要管理员权限 同时 再按一次 测试一下 有没有保存上 ,访问web浏览器测试网页的跳转 原文地址:https://www.cnblogs.com/wwtao/p/12037137.html

Linux学习笔记5-搭建内网Yum源

一.安装Nginx  1.安装依赖: [[email protected] local]# yum install gc-devel gcc-c++ pcre-devel zlib-devel 2.解压Nginx压缩包: [[email protected] local]# tar -zxvf nginx-1.8.0.tar.gz 3. 预编译 和 安装 [[email protected] local]# cd nginx-1.8.0 [[email protected] local]# ./

nginx配置官网yum源

以centos6.5 为例 1 登录Nginx下载页面 http://nginx.org/en/download.html 2 下拉点击stable version跳转 Pre-Built Packages Linux packages for stable version Linux packages for mainline version 3 vim /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://ngi

nginx转发内网站点保13 permission denied错误

用niginx 将内网站点临时开一个外网接口,一直报13错误 后来差了是selinux的原因 又不想整个关闭selinux 检查网络访问的配置 getsebool -a | grep httpd_can_network_connect 如结果如下 httpd_can_network_connect --> off 执行 setsebool -P httpd_can_network_connect 1 之后便能成功转发 原文地址:https://www.cnblogs.com/zym1414/p/