校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識(shí)庫 > nginx location中uri的截取的實(shí)現(xiàn)方法

nginx location中uri的截取的實(shí)現(xiàn)方法

熱門標(biāo)簽:廣州電銷機(jī)器人系統(tǒng)圖 智能電話機(jī)器人線路 長沙開福怎么申請(qǐng)400電話 高德地圖標(biāo)注無營業(yè)執(zhí)照 百度地圖標(biāo)注要不要錢 江蘇電銷外呼防封系統(tǒng)是什么 賀州市地圖標(biāo)注app 金融行業(yè)外呼線路 東莞人工智能電銷機(jī)器人供應(yīng)商

說明:

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/lctest4


location /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 $ curl http://tapi.xxxx.com/lctest/
hello world

root@pts/1 $ curl http://tapi.xxxx.com/lctest2/
hello world
2

root@pts/1 $ curl http://tapi.xxxx.com/lctest3/
3
hello world

root@pts/1 $ curl http://tapi.xxxx.com/lctest4/
hello world
4

location alias

location /lctest5 {
  alias /data/web/;
}
location /lctest6/ {
  alias /data/web/;
}

location /lctest7 {
  alias /data/web;
}

## 403 /data/web forbidden
location /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>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>

location proxy_pass

#--------proxy_pass配置---------------------
location /t1/ { proxy_pass http://servers; }  #正常,不截?cái)?
location /t2/ { proxy_pass http://servers/; }  #正常,截?cái)?
location /t3 { proxy_pass http://servers; }  #正常,不截?cái)?
location /t4 { proxy_pass http://servers/; }  #正常,截?cái)?
location /t5/ { proxy_pass http://servers/test/; }  #正常,截?cái)?
location /t6/ { proxy_pass http://servers/test; }  #缺"/",截?cái)?
location /t7 { proxy_pass http://servers/test/; }  #含"http://",截?cái)?
location /t8 { proxy_pass http://servers/test; }  #正常,截?cái)?

測(cè)試腳本

for i in $(seq 8)
do
  url=http://tapi.xxxx.com/t$i/doc/index.html
  echo "-----------$url-----------"
  curl url
done

測(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

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

標(biāo)簽:廊坊 滄州 松原 張家界 洛陽 永州 北京 玉樹

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《nginx location中uri的截取的實(shí)現(xiàn)方法》,本文關(guān)鍵詞  nginx,location,中,uri,的,截,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《nginx location中uri的截取的實(shí)現(xiàn)方法》相關(guān)的同類信息!
  • 本頁收集關(guān)于nginx location中uri的截取的實(shí)現(xiàn)方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 乐山市| 嵊州市| 武宁县| 娄烦县| 集安市| 濮阳县| 博兴县| 都安| 西丰县| 邵阳县| 河源市| 甘肃省| 泰和县| 松滋市| 吐鲁番市| 敦煌市| 玉树县| 通海县| 鲁甸县| 安达市| 黄骅市| 鲁甸县| 庄河市| 德庆县| 育儿| 彭阳县| 桂东县| 清河县| 霍山县| 永善县| 积石山| 江源县| 泊头市| 廉江市| 神木县| 凤阳县| 四平市| 自治县| 抚州市| 永嘉县| 山阴县|