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

解讀nginx反向代理location和proxy_pass的映射關(guān)系

 更新時(shí)間:2024年01月26日 14:21:24   作者:isea533  
這篇文章主要介紹了解讀nginx反向代理location和proxy_pass的映射關(guān)系,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

配置nginx反向代理時(shí),總是需要嘗試多次才能配置成功,通過(guò)本文做個(gè)記錄,方便以后查看。

1. proxy_pass 只有主機(jī)地址時(shí)

只有主機(jī)地址的意思是,proxy_pass 值為 http://host:port 這種形式,url部分沒(méi)有 //xxx 等.

對(duì)應(yīng)到本文示例就是 http://backend。

這種情況下,相當(dāng)于下面的公式:

backend url = proxy_pass + path

這種情況下,請(qǐng)求的 path 部分會(huì)直接追加到 proxy_pass 地址后,相當(dāng)于把nginx地址一對(duì)一的映射到了后端地址,這種配置方式理解最簡(jiǎn)單。

locationproxy_passpathnginx urlbackend url
/http://backend/http://nginx/http://backend/
/http://backend/hellohttp://nginx/hellohttp://backend/hello
/http://backend/hello/worldhttp://nginx/hello/worldhttp://backend/hello/world
locationproxy_passpathnginx urlbackend url
/ahttp://backend/ahttp://nginx/ahttp://backend/a
/ahttp://backend/abhttp://nginx/abhttp://backend/ab
/ahttp://backend/a/http://nginx/a/http://backend/a/
/ahttp://backend/a/bhttp://nginx/a/bhttp://backend/a/b
/ahttp://backend/a/b/http://nginx/a/b/http://backend/a/b/
locationproxy_passpathnginx urlbackend url
/b/http://backend/b/http://nginx/b/http://backend/b/
/b/http://backend/b/ahttp://nginx/b/ahttp://backend/b/a
/b/http://backend/b/a/http://nginx/b/a/http://backend/b/a/

2. proxy_pass 帶路徑時(shí)

這種情況下,相當(dāng)于下面的公式:

backend url = proxy_pass + (path - location)

path 部分減去匹配的 location 部分后,剩余內(nèi)容追加到 proxy_pass 上去請(qǐng)求。

如果不是為了 /u 去匹配 /uv 這種路徑,使用 /v/ 去匹配 /v/w 這種更準(zhǔn)確,不會(huì)出現(xiàn) // 這種情況。

locationproxy_passpathnginx urlbackend url
/uhttp://backend//uhttp://nginx/uhttp://backend/
/uhttp://backend//uvhttp://nginx/uvhttp://backend/v
/uhttp://backend//u/http://nginx/u/http://backend//
/uhttp://backend//u/vhttp://nginx/u/vhttp://backend//v
/uhttp://backend//u/v/http://nginx/u/v/http://backend//v/
locationproxy_passpathnginx urlbackend url
/v/http://backend//v/http://nginx/v/http://backend/
/v/http://backend//v/whttp://nginx/v/whttp://backend/w
/v/http://backend//v/w/http://nginx/v/w/http://backend/w/
locationproxy_passpathnginx urlbackend url
/chttp://backend/c/chttp://nginx/chttp://backend/c
/chttp://backend/c/cdhttp://nginx/cdhttp://backend/cd
/chttp://backend/c/c/http://nginx/c/http://backend/c/
/chttp://backend/c/c/dhttp://nginx/c/dhttp://backend/c/d
/chttp://backend/c/c/d/http://nginx/c/d/http://backend/c/d/
locationproxy_passpathnginx urlbackend url
/d/http://backend/d/d/http://nginx/d/http://backend/d
/d/http://backend/d/d/ehttp://nginx/d/ehttp://backend/de
/d/http://backend/d/d/e/http://nginx/d/e/http://backend/de/
locationproxy_passpathnginx urlbackend url
/ehttp://backend/e//ehttp://nginx/ehttp://backend/e/
/ehttp://backend/e//efhttp://nginx/efhttp://backend/e/f
/ehttp://backend/e//e/http://nginx/e/http://backend/e//
/ehttp://backend/e//e/fhttp://nginx/e/fhttp://backend/e//f
/ehttp://backend/e//e/f/http://nginx/e/f/http://backend/e//f/
locationproxy_passpathnginx urlbackend url
/f/http://backend/f//f/http://nginx/f/http://backend/f/
/f/http://backend/f//f/ghttp://nginx/f/ghttp://backend/f/g
/f/http://backend/f//f/g/http://nginx/f/g/http://backend/f/g/
locationproxy_passpathnginx urlbackend url
/ghttp://backend/m/ghttp://nginx/ghttp://backend/m
/ghttp://backend/m/ghhttp://nginx/ghhttp://backend/mh
/ghttp://backend/m/g/http://nginx/g/http://backend/m/
/ghttp://backend/m/g/hhttp://nginx/g/hhttp://backend/m/h
/ghttp://backend/m/g/h/http://nginx/g/h/http://backend/m/h/
locationproxy_passpathnginx urlbackend url
/h/http://backend/n/h/http://nginx/h/http://backend/n
/h/http://backend/n/h/ihttp://nginx/h/ihttp://backend/ni
/h/http://backend/n/h/i/http://nginx/h/i/http://backend/ni/
locationproxy_passpathnginx urlbackend url
/ihttp://backend/x//ihttp://nginx/ihttp://backend/x/
/ihttp://backend/x//ijhttp://nginx/ijhttp://backend/x/j
/ihttp://backend/x//i/http://nginx/i/http://backend/x//
/ihttp://backend/x//i/jhttp://nginx/i/jhttp://backend/x//j
/ihttp://backend/x//i/j/http://nginx/i/j/http://backend/x//j/
locationproxy_passpathnginx urlbackend url
/j/http://backend/y//j/http://nginx/j/http://backend/y/
/j/http://backend/y//j/khttp://nginx/j/khttp://backend/y/k
/j/http://backend/y//j/k/http://nginx/j/k/http://backend/y/k/
locationproxy_passpathnginx urlbackend url
/ws/http://backend/spring/ws//ws/qrloginhttp://nginx/ws/qrloginhttp://backend/spring/ws/qrlogin
/ws/http://backend/spring/ws//ws/stomphttp://nginx/ws/stomphttp://backend/spring/ws/stomp

參考文檔:

英文 - ngx_http_proxy_module.html#proxy_pass

中文 - ngx_http_proxy_module#proxy_pass

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

得荣县| 贵南县| 诏安县| 广昌县| 海城市| 信丰县| 金乡县| 罗定市| 宣恩县| 漳平市| 嫩江县| 姚安县| 射洪县| 临猗县| 清镇市| 乌拉特前旗| 宿州市| 隆昌县| 吉木乃县| 额敏县| 辽源市| 宿州市| 浪卡子县| 巴塘县| 潮安县| 庆阳市| 怀安县| 泗洪县| 仙游县| 东安县| 息烽县| 亳州市| 长武县| 成都市| 海城市| 金华市| 墨竹工卡县| 多伦县| 紫金县| 宁波市| 囊谦县|