part.0 使用背景
公司内网服务器不能直接通过Internet上网,但为了与外网通信和同步时间等,会指定那么几台服务器可以访问Internet。这里就是通过能上网的机器作为代理,制作内网使用的yum仓库。
part.1 环境
内网dns(推荐,非必须,因为可使用IP代替)
一台能上Internet的服务器A
不能上Internet的服务器能与A服务器通信
part.2 nginx安装
在可连接外网的A中安装nginx
yum install nginx
part.3 nginx配置
在主机A中添加nginx配置
$ cd /etc/nginx/conf.d $ vim proxy.conf
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/ ;
}
}
part.4 配置yum repo 源
修改无法连接外网的主机B 的repo文件。
$ 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








