part.0 使用背景
為尋甸等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及尋甸網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、成都外貿(mào)網(wǎng)站建設(shè)公司、尋甸網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
公司內(nèi)網(wǎng)服務(wù)器不能直接通過(guò)Internet上網(wǎng),但為了與外網(wǎng)通信和同步時(shí)間等,會(huì)指定那么幾臺(tái)服務(wù)器可以訪問(wèn)Internet。這里就是通過(guò)能上網(wǎng)的機(jī)器作為代理,制作內(nèi)網(wǎng)使用的yum倉(cāng)庫(kù)。
part.1 環(huán)境
內(nèi)網(wǎng)DNS(推薦,非必須,因?yàn)榭墒褂肐P代替)
一臺(tái)能上Internet的服務(wù)器A
不能上Internet的服務(wù)器能與A服務(wù)器通信
part.2 nginx安裝
在可連接外網(wǎng)的A中安裝nginx
yum install nginx
part.3 nginx配置
在主機(jī)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ú)法連接外網(wǎng)的主機(jī)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 主機(jī)IP 和后面的反向代理地址
part.6 配置iptables
ping mirrors.yourdomain.com #報(bào)錯(cuò) 沒(méi)有到主機(jī)的路由
此時(shí)查看B主機(jī)中的iptables信息,發(fā)現(xiàn)無(wú)法訪問(wè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 測(cè)試是否成功
在B主機(jī)中進(jìn)行,yum makecache操作。來(lái)判斷是否能進(jìn)行yum操作。
$ yum clean all $ yum makecache
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)創(chuàng)新互聯(lián)的支持。
標(biāo)題名稱:nginx反向代理進(jìn)行yum配置的步驟詳解
本文URL:http://chinadenli.net/article24/pgojce.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、動(dòng)態(tài)網(wǎng)站、定制開發(fā)、網(wǎng)站策劃、、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
網(wǎng)頁(yè)設(shè)計(jì)公司知識(shí)