欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解讀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í),總是需要嘗試多次才能配置成功,通過本文做個(gè)記錄,方便以后查看。

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

只有主機(jī)地址的意思是,proxy_pass 值為 http://host:port 這種形式,url部分沒有 //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)文章

  • Nginx實(shí)現(xiàn)TCP和UDP代理的方法步驟

    Nginx實(shí)現(xiàn)TCP和UDP代理的方法步驟

    Nginx 1.9.13 及以上版本支持TCP/UDP代理功能,通過配置監(jiān)聽端口、后端服務(wù)器地址等參數(shù),實(shí)現(xiàn)客戶端請(qǐng)求的轉(zhuǎn)發(fā)和響應(yīng)的返回,下面就來介紹一下如何實(shí)現(xiàn),感興趣的可以了解一下
    2024-12-12
  • nginx添加ssl模塊的方法教程

    nginx添加ssl模塊的方法教程

    這篇文章主要給大家介紹了關(guān)于nginx添加ssl模塊的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)許吧。
    2017-12-12
  • Nginx上傳文件出現(xiàn)“ 413 (499 502 404) Request Entity Too Large錯(cuò)誤解決

    Nginx上傳文件出現(xiàn)“ 413 (499 502 404) Requ

    HTTP 413 Request Entity Too Large錯(cuò)誤常常出現(xiàn)在客戶端發(fā)送的請(qǐng)求體超過服務(wù)器允許的大小限制時(shí),本文主要介紹了Nginx上傳文件出現(xiàn)“ 413 (499 502 404) Request Entity Too Large錯(cuò)誤解決,感興趣的可以了解一下
    2024-07-07
  • Nginx雙機(jī)熱備的實(shí)現(xiàn)步驟

    Nginx雙機(jī)熱備的實(shí)現(xiàn)步驟

    本文主要介紹了Nginx雙機(jī)熱備的實(shí)現(xiàn)步驟,是國(guó)內(nèi)企業(yè)中最為普遍的一種高可用方案,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-05-05
  • 制作能在nginx和IIS中使用的ssl證書

    制作能在nginx和IIS中使用的ssl證書

    現(xiàn)在的后端開發(fā),動(dòng)不動(dòng)就是需要https,或者說是需要ssl證書,既然沒有正版的證書,那么我們只能自己制作ssl的證書了。 證書的制作采用的是openssl工具,如果沒有,可以自行安裝下,因?yàn)楣P者是在linux(ubuntu)下制作,所以一般是使用包管理工具(apt)安裝好了的
    2021-06-06
  • Nginx中配置WebSocket代理的詳細(xì)步驟

    Nginx中配置WebSocket代理的詳細(xì)步驟

    Nginx 可以配置為 WebSocket 代理,將 WebSocket 連接從客戶端轉(zhuǎn)發(fā)到后端服務(wù)器,以下是如何在 Nginx 中配置 WebSocket 代理的詳細(xì)步驟和示例配置,需要的朋友可以參考下
    2025-02-02
  • Nginx丟棄http包體處理實(shí)例詳解

    Nginx丟棄http包體處理實(shí)例詳解

    這篇文章主要介紹了Nginx丟棄http包體處理實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • nginx worker進(jìn)程循環(huán)的實(shí)現(xiàn)

    nginx worker進(jìn)程循環(huán)的實(shí)現(xiàn)

    這篇文章主要介紹了nginx worker進(jìn)程循環(huán)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • nginx編譯安裝出現(xiàn)的常見錯(cuò)誤及解決方法

    nginx編譯安裝出現(xiàn)的常見錯(cuò)誤及解決方法

    這篇文章給大家介紹了nginx在編譯安裝過程中容易出現(xiàn)的常見錯(cuò)誤以及解決方法,文中有詳細(xì)的代碼講解,對(duì)我們的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2023-08-08
  • nginx fair負(fù)載均衡方式使用詳解

    nginx fair負(fù)載均衡方式使用詳解

    本文主要介紹了nginx fair負(fù)載均衡方式使用詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-08-08

最新評(píng)論