国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

Nginx反向代理的主要作用 Nginx反向代理三種模式介

發(fā)布時(shí)間:2022-09-04 14:30 來(lái)源:主機偵探 閱讀:159 作者:主機偵探 欄目: 服務(wù)器 歡迎投稿:712375056

Nginx是一款輕量級的Web 服務(wù)器/反向代理服務(wù)器及電子郵件(IMAP/POP3)代理服務(wù)器,其特點(diǎn)是占用內存少,并發(fā)能力強,是我們在Web開(kāi)發(fā)中最常用的工具之一。那么Nginx反向代理的主要作用有哪些?有幾種常用模式呢?下面一起來(lái)了解下。

Nginx反向代理的主要作用

Nginx配置反向代理時(shí),是安裝在目的主機端,主要用于轉發(fā)客戶(hù)機請求,后臺有多個(gè)http服務(wù)器提供服務(wù),Nginx的功能就是把請求轉發(fā)給后面的服務(wù)器,決定哪臺目標主機來(lái)處理當前請求。

此外,Nginx能提供性能穩定、并且提供配置靈活的轉發(fā)功能。它可以根據不同的正則匹配,采取不同的轉發(fā)策略,并且Nginx對返回結果進(jìn)行錯誤頁(yè)跳轉,異常判斷等。如果被分發(fā)的服務(wù)器存在異常,它可以將請求重新轉發(fā)給另外一臺服務(wù)器,然后自動(dòng)去除異常服務(wù)器。

相關(guān)閱讀:《Nginx反向代理服務(wù)器配置教程》

Nginx反向代理的三種模式

1、基于IP代理

2、基于域名代理

3、基于端口代理

nginx.conf

worker_processes  1;

events {

worker_connections  1024;

}

http {

charset utf-8;

include       mime.types;

default_type  application/octet-stream;

log_format  main  ‘$remote_addr – $remote_user [$time_local] “$request” ‘

‘$status $body_bytes_sent “$http_referer” ‘

‘”$http_user_agent” “$http_x_forwarded_for”‘;

# log_format  main  ‘remote_addr=$remote_addr:$remote_port, http_x_forwarded_for=$http_x_forwarded_for, proxy_add_x_forwarded_for=$proxy_add_x_forwarded_for ‘;

access_log  logs/access_format.log  main;

sendfile    on;

#tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  65;

#gzip  on

# 原始server

server {

listen   80;

server_name  localhost;

location / {

root   html;

index  index.html index.htm;

}

}

# 引入自定義的server配置

include my-proxy-server.conf;

}

my-proxy-server.conf

基于端口代理

server {

listen   81;

server_name  localhost;

location / {

proxy_pass http://192.168.0.153:9091;

proxy_redirect default;

}

location = /50x.html {

root   html;

}

}

server {

listen 82;

server_name  localhost;

location / {

proxy_pass http://git.itplh.com;

proxy_redirect default;

}

location = /50x.html {

root   html;

}

}

# 基于域名代理 gitlocal負載均衡

upstream gitlocal{

server 192.168.0.153:9091;

server 192.168.0.154:9091;

server 192.168.0.155:9091;

}

upstream gitbj{

server git.itplh.con;

}

server {

listen  80;

server_name  gitlocal.com;

location / {

proxy_pass http://gitlocal;

proxy_redirect default;

}

location = /50x.html {

root   html;

}

}

server {

listen       80;

server_name  gitbj.com;

location / {

proxy_pass http://gitbj;

proxy_redirect default;

}

location = /50x.html {

root   html;

}

來(lái)源鏈接:https://www.idcspy.com/31442.html

本站聲明:網(wǎng)站內容來(lái)源于網(wǎng)絡(luò ),如有侵權,請聯(lián)系我們,我們將及時(shí)處理。

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

亚洲AV成人无码精品网站 | 亚洲欧洲日韩国内高清| 夜鲁鲁鲁夜夜综合视频欧美| 少妇人妻综合久久中文字幕| 亚洲AV无码日韩AV无码伊甸园| 亚洲老熟女@TubeumTV|