最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2018年12月30日 09:13:45   作者:偏執(zhí)可破頑石  
這篇文章主要給大家介紹了關于nginx反向代理進行yum配置的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

part.0 使用背景

公司內網(wǎng)服務器不能直接通過Internet上網(wǎng),但為了與外網(wǎng)通信和同步時間等,會指定那么幾臺服務器可以訪問Internet。這里就是通過能上網(wǎng)的機器作為代理,制作內網(wǎng)使用的yum倉庫。

part.1 環(huán)境

內網(wǎng)dns(推薦,非必須,因為可使用IP代替)

一臺能上Internet的服務器A

不能上Internet的服務器能與A服務器通信

part.2 nginx安裝

在可連接外網(wǎng)的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 源

修改無法連接外網(wǎng)的主機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信息,發(fā)現(xiàn)無法訪問80,可以在最前添加一條規(guī)則。

$ 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服務器下配置StartSSL和SSL的教程

    在Nginx服務器下配置StartSSL和SSL的教程

    這篇文章主要介紹了在Nginx服務器下配置StartSSL和SSL的教程,其中申請證書的步驟確實比較麻煩一些,不過出于安全考慮:p需要的朋友可以參考下
    2015-07-07
  • 一文弄懂Nginx的location匹配的實現(xiàn)

    一文弄懂Nginx的location匹配的實現(xiàn)

    這篇文章主要介紹了一文弄懂Nginx的location匹配的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-02-02
  • nginx實現(xiàn)負載均衡與實例解讀

    nginx實現(xiàn)負載均衡與實例解讀

    這篇文章主要介紹了nginx實現(xiàn)負載均衡與實例,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • nginx 與后臺端口沖突的解決

    nginx 與后臺端口沖突的解決

    這篇文章主要介紹了nginx 與后臺端口沖突的解決,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-03-03
  • Nginx 配置過程的具體步驟

    Nginx 配置過程的具體步驟

    這篇文章主要介紹了Nginx 配置過程的詳細介紹的相關資料,希望通過本文能幫助到大家,讓大家掌握如何配置Nginx,需要的朋友可以參考下
    2017-10-10
  • Nginx反代Mogilefs分布式儲存示例詳解

    Nginx反代Mogilefs分布式儲存示例詳解

    這篇文章主要給大家介紹了關于Nginx反代Mogilefs分布式儲存的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用Nginx具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2018-11-11
  • nginx超時設置詳細介紹

    nginx超時設置詳細介紹

    這篇文章主要介紹了nginx超時設置詳細介紹的相關資料,需要的朋友可以參考下
    2017-05-05
  • 定期刪除OpenResty/Nginx大日志文件的方法

    定期刪除OpenResty/Nginx大日志文件的方法

    這篇文章主要介紹了定期刪除OpenResty/Nginx大日志文件的方法,文中通過代碼示例給大家講解的非常詳細,對大家的學習或工作有一定的幫助,需要的朋友可以參考下
    2024-05-05
  • nginx服務器access日志中大量400 bad request錯誤的解決方法

    nginx服務器access日志中大量400 bad request錯誤的解決方法

    這篇文章主要介紹了nginx服務器access日志中大量400 bad request錯誤的解決方法,本文結論是空主機頭導致的大量400錯誤日志,關閉默認主機的日志記錄就可以解決問題,需要的朋友可以參考下
    2015-01-01
  • 使用?nginx?搭建代理服務器(正向代理?https?網(wǎng)站)的詳細步驟

    使用?nginx?搭建代理服務器(正向代理?https?網(wǎng)站)的詳細步驟

    這篇文章主要介紹了使用?nginx?搭建代理服務器(正向代理?https?網(wǎng)站)指南的相關操作,本文給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧
    2024-08-08

最新評論

二连浩特市| 青浦区| 大厂| 庆元县| 江山市| 广宗县| 金沙县| 云龙县| 铁力市| 新闻| 桐柏县| 南安市| 广安市| 东安县| 无极县| 呈贡县| 济阳县| 原平市| 余干县| 黄梅县| 长治市| 大姚县| 报价| 浑源县| 弥勒县| 离岛区| 三河市| 任丘市| 渭南市| 耿马| 甘泉县| 双牌县| 河西区| 灵丘县| 唐海县| 白河县| 潍坊市| 商南县| 芜湖市| 昔阳县| 黎平县|