婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Nginx location 和 proxy_pass路徑配置問題小結(jié)

Nginx location 和 proxy_pass路徑配置問題小結(jié)

熱門標(biāo)簽:藍(lán)點外呼系統(tǒng) 烏海智能電話機(jī)器人 400電話申請方案 威海人工外呼系統(tǒng)供應(yīng)商 做外呼系統(tǒng)的公司違法嗎 貴陽教育行業(yè)電話外呼系統(tǒng) 寧夏房產(chǎn)智能外呼系統(tǒng)要多少錢 撫順移動400電話申請 在百度地圖標(biāo)注車輛

本文是基于 location 的匹配末尾是否配置 / 和 proxy_pass 末尾是否配置 / ,進(jìn)行測試,完全還原了整個測試過程。幫助了解具體的情況。

一、Nginx location 基本配置

1.1、Nginx 配置文件

upstream test1{
server 127.0.0.1:8000;
}
upstream test2{
server 127.0.0.1:8000;
}
server{
	server_name  test.com;
	listen 80;
        access_log /usr/local/openresty/nginx/logs/test.com_access.log latest;
        error_log  /usr/local/openresty/nginx/logs/test.com.log error;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_connect_timeout   3s;
        proxy_read_timeout 120s;
        proxy_send_timeout 120s;
        proxy_next_upstream error timeout invalid_header http_404 http_502 http_504 http_500;
	
        location /user/ {
			proxy_set_header Connection "";
        	proxy_http_version 1.1;
			proxy_pass http://test1/;
		}
        location / {
                proxy_set_header Connection "";
                proxy_http_version 1.1;
                proxy_pass http://test2/;
        }
}

1.2 、Python 腳本

python2 可以運(yùn)行

該腳本用于獲取請求內(nèi)容。 這個作為后端,也就是 proxy_pass 代理的后端。

#!/usr/bin/env python

import SimpleHTTPServer
import SocketServer

PORT = 8000

class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
        print(self.headers)
        self.send_response(200, "")
    def do_POST(self):
        print(self.headers)
        content_length = self.headers.getheaders('content-length')
        length = int(content_length[0]) if content_length else 0
        print(self.rfile.read(length))
        self.send_response(200, "")

Handler = GetHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
httpd.serve_forever()

二、測試

2.1、測試 location

末尾存在 / 和 proxy_pass末尾存在 /

nginx配置如下

 location /user/ {
			proxy_set_header Connection "";
        	proxy_http_version 1.1;
			proxy_pass http://test1/;
		}

請求url

test.com/user/test.html

后端內(nèi)容

打印的內(nèi)容:

Host: test1
Content-Length: 0
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: f2bfe770-4f44-4ee9-91c4-060f59dfb26c
Accept-Encoding: gzip, deflate, br


127.0.0.1 - - [10/Apr/2021 16:54:26] "POST /test.html HTTP/1.1" 200 -

小結(jié)論:proxy_pass 地址加了 / 的話, 請求 test.com/user/test.html 實際請求是 http://test1/test.html

2.2、測試 location

末尾存在 / 和 proxy_pass末尾不存在 /

nginx配置如下

 location /user/ {
			proxy_set_header Connection "";
        	proxy_http_version 1.1;
			proxy_pass http://test1;
		}

請求url

test.com/user/test.html

后端內(nèi)容

打印的內(nèi)容:

Host: test1
Content-Length: 0
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: e33d0a2c-1965-4152-b87c-94fca50f2899
Accept-Encoding: gzip, deflate, br

127.0.0.1 - - [10/Apr/2021 16:57:18] "POST /user/test.html HTTP/1.1" 200 -

小結(jié)論: proxy_pass 地址不加了 / 的話, 請求 test.com/user/test.html 實際請求是 http://test1/user/test.html

2.3、測試三 location

不加末尾 / 且 proxy_pass 不加 末尾 /

nginx配置如下

 location /user {
			proxy_set_header Connection "";
        	proxy_http_version 1.1;
			proxy_pass http://test1;
		}

請求url

test.com/user/test.html

后端內(nèi)容

打印的內(nèi)容:

Host: test1
Content-Length: 0
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: 31cd33c6-4c95-41b5-a095-28cdc7113dcd
Accept-Encoding: gzip, deflate, br

127.0.0.1 - - [10/Apr/2021 16:59:34] "POST /user/test.html HTTP/1.1" 200 -

請求 test.com/user/test.html 實際請求是 http://test1/user/test.html

2.4、location 不加

末尾 / 且 proxy_pass 加 末尾 /

nginx配置如下

  location /user {
			proxy_set_header Connection "";
        	proxy_http_version 1.1;
			proxy_pass http://test1/;
		}

請求url

test.com/user/test.html

后端內(nèi)容

打印的內(nèi)容:

Host: test1
Content-Length: 0
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: d0f4b83f-6482-41ba-8a01-c059eececc2d
Accept-Encoding: gzip, deflate, br

127.0.0.1 - - [10/Apr/2021 17:00:21] "POST //test.html HTTP/1.1" 200 -

請求 test.com/user/test.html 實際請求是 http://test1//test.html

2.5、location 末尾

/ proxy_pass 末尾其他有路徑,且末尾加 /

nginx配置如下

   location /user/ {
			proxy_set_header Connection "";
        	proxy_http_version 1.1;
			proxy_pass http://test1/haha/;
		}

請求url

test.com/user/test.html

后端內(nèi)容

打印的內(nèi)容:

Host: test1
Content-Length: 0
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: 6447cf0b-5988-4f96-81a4-2b621fe32604
Accept-Encoding: gzip, deflate, br

127.0.0.1 - - [10/Apr/2021 17:03:27] "POST /haha/test.html HTTP/1.1" 200 -

請求 test.com/user/test.html 實際請求是 http://test1/haha/test.html

2.6、 location 末尾

/ proxy_pass 末尾其他有路徑,且末尾不加 /

nginx配置如下

 location /user/ {
			proxy_set_header Connection "";
        	proxy_http_version 1.1;
			proxy_pass http://test1/haha;
		}

請求url

test.com/user/test.html

后端內(nèi)容

打印的內(nèi)容:

Host: test1
Content-Length: 0
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: 32fb2a50-1e7c-4131-9804-1828e21ca841
Accept-Encoding: gzip, deflate, br

127.0.0.1 - - [10/Apr/2021 17:05:03] "POST /hahatest.html HTTP/1.1" 200 -

請求 test.com/user/test.html 實際請求是 http://test1/hahatest.html

三、總結(jié)

序號 訪問URL location配置 proxy_pass配置 后端接收的請求 備注
1 test.com/user/test.html /user/ http://test1/ /test.html
2 test.com/user/test.html /user/ http://test1 /user/test.html
3 test.com/user/test.html /user http://test1 /user/test.html
4 test.com/user/test.html /user http://test1/ //test.html
5 test.com/user/test.html /user/ http://test1/haha/ /haha/test.html
6 test.com/user/test.html /user/ http://test1/haha /hahatest.html

注意上表格中的后端是指 python 腳本對應(yīng)的web服務(wù)。

在日常的web網(wǎng)站部署中,經(jīng)常會用到 nginxproxy_pass 反向代理,有一個配置需要弄清楚:配置 proxy_pass 時,

  • 當(dāng)在后面的 upstram_name 后面出現(xiàn)了 /,相當(dāng)于是絕對根路徑,則 nginx 不會把 location 中匹配的路徑部分代理走;
  • 如果沒有 /,則會把匹配的路徑部分也給代理走。

到此這篇關(guān)于Nginx location 和 proxy_pass路徑配置詳解的文章就介紹到這了,更多相關(guān)Nginx location 和 proxy_pass路徑配置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

標(biāo)簽:泰州 慶陽 松原 銅川 朝陽 蕪湖 周口 那曲

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Nginx location 和 proxy_pass路徑配置問題小結(jié)》,本文關(guān)鍵詞  Nginx,location,和,proxy,pass,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Nginx location 和 proxy_pass路徑配置問題小結(jié)》相關(guān)的同類信息!
  • 本頁收集關(guān)于Nginx location 和 proxy_pass路徑配置問題小結(jié)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    久久成人综合网| 国产高清精品网站| 欧美一区二区私人影院日本| 亚洲午夜激情网站| 99国产一区二区三精品乱码| 91美女精品福利| 国产成a人亚洲精| 麻豆精品一区二区av白丝在线| 日本一区二区免费在线观看视频 | 日韩黄色一级片| 欧美日韩国产免费一区二区| 午夜视频一区在线观看| 国产欧美日韩综合| 国产精品一区二区在线播放| 亚洲综合免费观看高清完整版在线| 欧洲激情一区二区| 国产成人av福利| 国产一区二区精品久久| 国产精品久久夜| 欧美浪妇xxxx高跟鞋交| 欧美亚洲高清一区| 国产一二三精品| 国内精品伊人久久久久av影院 | 国产iv一区二区三区| 麻豆精品一区二区三区| 爽好久久久欧美精品| 亚洲人亚洲人成电影网站色| 日韩一区二区免费电影| eeuss鲁片一区二区三区在线看| 国产成人午夜精品5599| 成人a区在线观看| 国产福利一区二区三区| 蜜桃一区二区三区四区| 久久99久久精品| 极品少妇一区二区| 国v精品久久久网| 成人免费观看av| 经典一区二区三区| 91视频你懂的| 久久噜噜亚洲综合| 洋洋成人永久网站入口| 另类小说一区二区三区| 成人av在线网站| 欧美日韩成人综合天天影院| 久久久亚洲午夜电影| 国产免费观看久久| 亚洲精品一二三区| 一区二区欧美精品| 久久国产视频网| 成人黄色av网站在线| 久久综合久色欧美综合狠狠| 国产精品麻豆网站| 亚洲电影欧美电影有声小说| 久久免费偷拍视频| 国产精品嫩草影院av蜜臀| 国产精品私人影院| 亚洲激情综合网| 精品在线一区二区| 成人手机电影网| 欧美一区二区三区四区久久 | 亚洲成av人在线观看| 日韩在线观看一区二区| 亚洲午夜电影网| 色狠狠av一区二区三区| 欧美偷拍一区二区| 亚洲欧美日韩系列| 日韩和的一区二区| 91亚洲精华国产精华精华液| www.亚洲人| 欧美另类久久久品| 久久国产人妖系列| 欧美成人精品福利| 裸体歌舞表演一区二区| 欧美最猛黑人xxxxx猛交| 亚洲欧美日韩国产综合| 久久国产精品色| 国模无码大尺度一区二区三区| 国产福利91精品一区二区三区| 中文字幕高清不卡| 一区二区三区免费在线观看| 日本高清视频一区二区| 国产欧美日韩在线视频| 亚洲国产裸拍裸体视频在线观看乱了| 国精产品一区一区三区mba桃花| 国产成人精品免费在线| 成人免费毛片app| 亚洲一区二区三区中文字幕在线| 欧美aaa在线| 91精品国产综合久久久久久| 国产盗摄精品一区二区三区在线| 51精品久久久久久久蜜臀| 欧美在线一区二区三区| 久久国内精品自在自线400部| 欧美怡红院视频| 精品一区二区三区在线观看| 丁香婷婷综合激情五月色| 欧美一区2区视频在线观看| 天使萌一区二区三区免费观看| 欧美亚洲精品一区| 激情综合网最新| 午夜视频在线观看一区二区三区 | 制服丝袜成人动漫| 精品人伦一区二区色婷婷| 日韩欧美国产成人一区二区| 国产亚洲精品久| 国产欧美一区二区三区在线看蜜臀 | www.视频一区| 中文字幕欧美日本乱码一线二线| 亚洲欧美日韩中文播放| 午夜欧美在线一二页| 国产一区二区精品久久91| 激情综合色播激情啊| 九九精品一区二区| 亚洲精品乱码久久久久久久久| 亚洲欧洲日韩女同| 亚洲欧美激情视频在线观看一区二区三区 | 一区二区三区日本| 欧美日韩国产影片| 粉嫩蜜臀av国产精品网站| 一本大道久久a久久综合婷婷| 色欧美日韩亚洲| 欧美高清dvd| 亚洲国产成人午夜在线一区| 粉嫩av一区二区三区在线播放| 国产专区欧美精品| 狠狠色狠狠色合久久伊人| 青青青爽久久午夜综合久久午夜 | 日韩欧美国产综合| 精品理论电影在线| 一区二区三区免费观看| 国产高清久久久| 成人动漫av在线| 欧美日韩午夜在线| 欧美私人免费视频| 欧洲人成人精品| 97精品超碰一区二区三区| 久久久蜜臀国产一区二区| 亚洲免费观看在线视频| 1024成人网| 欧美视频完全免费看| 久久综合狠狠综合| 亚洲欧美偷拍三级| 国产精品538一区二区在线| 欧美成人精品3d动漫h| 亚洲午夜激情网页| 成人久久18免费网站麻豆| 午夜av电影一区| 国产精品欧美一级免费| 欧美一级片在线观看| 久久这里只有精品首页| 国产亚洲精品精华液| 日韩理论片在线| 日韩在线a电影| 久久av资源网| 国产精品青草久久| 经典三级在线一区| 国产精品理论片| 国产专区欧美精品| 日韩国产精品久久久久久亚洲| 91精品国产综合久久香蕉的特点 | 视频一区二区三区在线| 日一区二区三区| www.性欧美| 色综合久久99| 欧美日韩成人在线一区| 国产精品麻豆网站| 亚洲午夜国产一区99re久久| 亚洲综合图片区| av不卡在线播放| 777奇米四色成人影色区| 亚洲视频精选在线| 日本午夜一区二区| 国产一区二区不卡在线| 6080午夜不卡| 中文字幕精品—区二区四季| 一区二区三区蜜桃| 成人av资源站| 欧美一级在线免费| 亚洲午夜三级在线| 国产精品69久久久久水密桃| 欧美在线短视频| 国产精品第四页| 奇米色一区二区| 成人av动漫在线| 久久精品日韩一区二区三区| 亚洲欧美国产77777| 青娱乐精品在线视频| 欧美一区二区网站| 久久久精品影视| 久久精品国产精品亚洲精品| 色综合天天综合给合国产| 中文字幕成人网| 美女诱惑一区二区| 91久久免费观看| 亚洲精品视频免费看| 国产精品1024| 欧美一二三区在线观看| 日韩精品久久久久久| 99r国产精品| 欧美吻胸吃奶大尺度电影 |