nginx location中uri的截取

發(fā)布時(shí)間:2024-04-14
服務(wù)器
這篇文章給大家介紹nginx location中uri的截取,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
說(shuō)明:
location 中的 root 和 alias
root 指令只是將搜索的根設(shè)置為 root 設(shè)定的目錄,即不會(huì)截?cái)?uri,而是使用原始 uri 跳轉(zhuǎn)該目錄下查找文件
aias 指令則會(huì)截?cái)嗥ヅ涞?uri,然后使用 alias 設(shè)定的路徑加上剩余的 uri 作為子路徑進(jìn)行查找
location 中的 proxy_pass 的 uri
如果 proxy_pass 的 url 不帶 uri
如果尾部是\”/\”,則會(huì)截?cái)嗥ヅ涞膗ri
如果尾部不是\”/\”,則不會(huì)截?cái)嗥ヅ涞膗ri
如果proxy_pass的url帶uri,則會(huì)截?cái)嗥ヅ涞膗ri
examples
location中的 root
root@pts/1$ls-ld/data/web/lctest*|awk\'{print$nf}\’/data/web/lctest/data/web/lctest2/data/web/lctest3/data/web/lctest4location/lctest{root/data/web/;}location/lctest2/{root/data/web/;}location/lctest3{root/data/web;}location/lctest4/{root/data/web;}
curl 測(cè)試結(jié)果如下
備注: 瀏覽器輸入的時(shí)候最后面不添加 / , 會(huì)自動(dòng)補(bǔ)上,但是curl 不行
root@pts/1$curlhttp://tapi.xxxx.com/lctest/helloworldroot@pts/1$curlhttp://tapi.xxxx.com/lctest2/helloworld2root@pts/1$curlhttp://tapi.xxxx.com/lctest3/3helloworldroot@pts/1$curlhttp://tapi.xxxx.com/lctest4/helloworld4
location alias
location/lctest5{alias/data/web/;}location/lctest6/{alias/data/web/;}location/lctest7{alias/data/web;}##403/data/webforbiddenlocation/lctest8/{alias/data/web;}
curl 測(cè)試結(jié)果如下
curl\’http://tapi.kaishustory.com/lctest5/\’curl\’http://tapi.kaishustory.com/lctest6/\’curl\’http://tapi.kaishustory.com/lctest7/\’結(jié)果都是/data/web/index.html的輸出root@pts/1$curl\’http://tapi.kaishustory.com/lctest8/\'<html><head><title>403forbidden</title></head><bodybgcolor=\”white\”><center><h2>403forbidden</h2></center><hr><center>nginx</center></body></html>
location proxy_pass
#——–proxy_pass配置———————location/t1/{proxy_passhttp://servers;}#正常,不截?cái)鄉(xiāng)ocation/t2/{proxy_passhttp://servers/;}#正常,截?cái)鄉(xiāng)ocation/t3{proxy_passhttp://servers;}#正常,不截?cái)鄉(xiāng)ocation/t4{proxy_passhttp://servers/;}#正常,截?cái)鄉(xiāng)ocation/t5/{proxy_passhttp://servers/test/;}#正常,截?cái)鄉(xiāng)ocation/t6/{proxy_passhttp://servers/test;}#缺\”/\”,截?cái)鄉(xiāng)ocation/t7{proxy_passhttp://servers/test/;}#含\”//\”,截?cái)鄉(xiāng)ocation/t8{proxy_passhttp://servers/test;}#正常,截?cái)?br>測(cè)試腳本
foriin$(seq8)dourl=http://tapi.xxxx.com/t$i/doc/index.htmlecho\”———–$url———–\”curlurldone
測(cè)試結(jié)果
———-http://tapi.xxxx.com/t1/doc/index.html————/t1/doc/index.html———-http://tapi.xxxx.com/t2/doc/index.html————/doc/index.html———-http://tapi.xxxx.com/t3/doc/index.html————/t3/doc/index.html———-http://tapi.xxxx.com/t4/doc/index.html————/doc/index.html———-http://tapi.xxxx.com/t5/doc/index.html————/test/doc/index.html———-http://tapi.xxxx.com/t6/doc/index.html————/testdoc/index.html———-http://tapi.xxxx.com/t7/doc/index.html————/test//doc/index.html———-http://tapi.xxxx.com/t8/doc/index.html————/test/doc/index.html
關(guān)于nginx location中uri的截取就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
上一個(gè):翠云草銹病防治
下一個(gè):數(shù)控彎管機(jī)購(gòu)買時(shí)需要注意哪幾點(diǎn)

蘋果瀏覽器怎么下載軟件(蘋果瀏覽器怎么下載安裝文件)
電機(jī)故障檢測(cè)儀的特性及預(yù)防維護(hù)
招搖撞騙罪既遂標(biāo)準(zhǔn)
哈威電磁閥WGZ3-1-WG230庫(kù)存
TGSG-01W聲光報(bào)警器技術(shù)參數(shù)AC220V
如何通過(guò)VB實(shí)現(xiàn)PC機(jī)與PLC的以太網(wǎng)通信
內(nèi)盤管不銹鋼反應(yīng)釜操作規(guī)程
犯罪過(guò)失分為哪兩種
管道支撐墊木主要用于支持低溫管道系統(tǒng) 化工系統(tǒng)
管式爐的使用維護(hù)及培養(yǎng)溫度
十八禁 网站在线观看免费视频_2020av天堂网_一 级 黄 色 片免费网站_绝顶高潮合集Videos