婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > nginx反向代理進行yum配置的步驟詳解

nginx反向代理進行yum配置的步驟詳解

熱門標簽:涪陵商都400電話開通辦理 外呼系統不彈窗 廈門營銷外呼系統平臺 云會外呼系統 申請400電話價格多少 智能電話機器人坐席 柳州市機器人外呼系統報價 安陽ai電銷機器人軟件 外呼系統的經營范圍

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

part.5 配置hosts

$ cat /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1   localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.193 mirrors.yourdomain.com
# 確保A 主機IP 和后面的反向代理地址

part.6 配置iptables

ping mirrors.yourdomain.com
#報錯 沒有到主機的路由

此時查看B主機中的iptables信息,發現無法訪問80,可以在最前添加一條規則。

$ iptables -nvL

 8155 28M ACCEPT  all -- *  *  0.0.0.0/0   0.0.0.0/0   ctstate RELATED,ESTABLISHED
 0  0 ACCEPT  all -- lo  *  0.0.0.0/0   0.0.0.0/0   
11761 985K INPUT_direct all -- *  *  0.0.0.0/0   0.0.0.0/0   
11761 985K INPUT_ZONES_SOURCE all -- *  *  0.0.0.0/0   0.0.0.0/0   
11761 985K INPUT_ZONES all -- *  *  0.0.0.0/0   0.0.0.0/0   
 0  0 DROP  all -- *  *  0.0.0.0/0   0.0.0.0/0   ctstate INVALID
11756 985K REJECT  all -- *  *  0.0.0.0/0   0.0.0.0/0   reject-with icmp-host-prohibited
$ iptables -I INPUT -p tcp --dport 80 -j ACCEPT

part.7 測試是否成功

在B主機中進行,yum makecache操作。來判斷是否能進行yum操作。

$ yum clean all
$ yum makecache

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

標簽:福州 蕪湖 晉城 撫順 綏化 孝感 南充 巴中

巨人網絡通訊聲明:本文標題《nginx反向代理進行yum配置的步驟詳解》,本文關鍵詞  nginx,反向,代理,進行,yum,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《nginx反向代理進行yum配置的步驟詳解》相關的同類信息!
  • 本頁收集關于nginx反向代理進行yum配置的步驟詳解的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 班戈县| 屏南县| 天等县| 临武县| 江源县| 扶风县| 拜城县| 大庆市| 夏津县| 新晃| 福贡县| 呼玛县| 永清县| 南丰县| 仙游县| 玉环县| 新巴尔虎右旗| 西乌珠穆沁旗| 南通市| 搜索| 五莲县| 长汀县| 双牌县| 达日县| 武强县| 洞头县| 桂林市| 酒泉市| 惠来县| 潮安县| 凤山县| 凭祥市| 宜春市| 正安县| 清河县| 平舆县| 蒙山县| 襄汾县| 马关县| 禹城市| 山东|