日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Centos7實(shí)現(xiàn)nginx反向代理

反向代理服務(wù)器架設(shè)在服務(wù)器端,通過(guò)緩沖經(jīng)常被請(qǐng)求的頁(yè)面來(lái)緩解服務(wù)器的工作量,將客戶機(jī)請(qǐng)求轉(zhuǎn)發(fā)給內(nèi)部網(wǎng)絡(luò)上的目標(biāo)服務(wù)器;并將從服務(wù)器上得到的結(jié)果返回給Internet上請(qǐng)求連接的客戶端,此時(shí)代理服務(wù)器與目標(biāo)主機(jī)一起對(duì)外表現(xiàn)為一個(gè)服務(wù)器。目前web網(wǎng)站使用反向代理,除了可以防止外網(wǎng)對(duì)內(nèi)網(wǎng)服務(wù)器的惡性攻擊、緩存以減少服務(wù)器的壓力和訪問(wèn)安全控制之外,下面為大家詳細(xì)講解一下Centos7實(shí)現(xiàn)nginx反向代理具體方法

成都創(chuàng)新互聯(lián)專(zhuān)注于企業(yè)成都全網(wǎng)營(yíng)銷(xiāo)推廣、網(wǎng)站重做改版、桐城網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、成都h5網(wǎng)站建設(shè)、電子商務(wù)商城網(wǎng)站建設(shè)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為桐城等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。

實(shí)驗(yàn)環(huán)境:

192.168.1.188 nginx負(fù)載均衡器

192.168.1.189 web01服務(wù)器

192.168.1.190 web02服務(wù)器

軟件準(zhǔn)備:

centos7.4 x86_64

nginx-1.6.3.tar.gz

安裝nginx軟件

安裝依賴(lài)軟件包命令集合

[root@localhost ~]# yum -y install openssl openssl-devel pcre pcre-devel gcc

安裝nginx軟件包命令集合

[root@localhost ~]# mkdir /app

[root@localhost ~]# cd /app

[root@localhost ~]# wget -q http://nginx.org/download/nginx-1.6.3.tar.gz

[root@localhost ~]# useradd -s /sbin/nologin -M

[root@localhost ~]# tar xf nginx-1.6.3.tar.gz

[root@localhost ~]# cd nginx-1.6.3

[root@localhost ~]# ./configure --user=nginx --group=nginx --prefix=/app/nginx --with-http_stub_status_module --with-http_ssl_module

[root@localhost ~]# make && make install

配置文件

(以下操作在web01和web02上進(jìn)行)

[root@localhost ~]# vim /app/nginx/conf/nginx.conf

將配置文件修改為以下內(nèi)容

worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "http_referer" '
'"$http_user_agent" " $http_x_forwarded_for"';
server {
listen 80;
server_name bbs.dengchuanghai.org;
location / {
root html/bbs;
index index.html index.htm;
}
access_log logs/access_bbs.log main;
}

}
[root@localhost ~]# mkdir /app/nginx/html/bbs

[root@localhost ~]# echo "192.168.1.189 bbs" >>/app/nginx/html/bbs/index.html            

[root@localhost ~]# echo "192.168.1.189 bbs.dengchuanghai.org" >> /etc/hosts                    

[root@localhost ~]# echo "192.168.1.190 bbs" >>/app/nginx/html/bbs/index.html  

[root@localhost ~]# echo "192.168.1.190 bbs.dengchuanghai.org" >> /etc/hosts

(分別在兩臺(tái)web服務(wù)器上輸入以上內(nèi)容)

然后分別啟動(dòng)nginx

[root@localhost ~]# /app/nginx/sbin/nginx -t (檢查配置文件有無(wú)錯(cuò)誤)

[root@localhost ~]# /app/nginx/sbin/nginx  啟動(dòng)

[root@localhost ~]# ss -tnlp | grep 80

使用curl bbs.dengch ,以下操作在nginx負(fù)載均衡器上進(jìn)行

[root@localhost ~]# vim /app/nginx/conf/nginx.conf

更改為如下內(nèi)容

worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream www_server_pools{
server 192.168.1.190:80 weight=1;
server 192.168.1.189:80 weight=1;
}
server {
listen 80;
server_name www.dengchuanghai.org;
location / {
proxy_pass http://www_server_pools;
}
}
}
[root@localhost ~]# echo "192.168.1.188 www.dengchuanghai,org" >> /etc/hosts

檢查語(yǔ)法

[root@localhost ~]# /app/nginx/sbin/nginx -t

啟動(dòng)服務(wù)

[root@localhost ~]# /app/nginx/sbin/nginx

使用curl www.dengchuanghai.org 發(fā)現(xiàn)結(jié)果輸出為兩臺(tái)服務(wù)器輪流輸出


當(dāng)前題目:Centos7實(shí)現(xiàn)nginx反向代理
分享地址:http://www.dlmjj.cn/article/djhdpei.html