• <rp id="ibjxb"><kbd id="ibjxb"></kbd></rp>
    \n

    403 forbidden<\/h1><\/center>\n
    nginx<\/center>\n<\/body>\n<\/html><\/pre>

    location proxy_pass<\/strong><\/p>

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

    測(cè)試腳本<\/strong><\/p>

    for i in $(seq 8)\ndo\n  url=http:\/\/tapi.xxxx.com\/t$i\/doc\/index.html\n  echo \"-----------$url-----------\"\n  curl url\ndone<\/pre>

    測(cè)試結(jié)果<\/strong><\/p>

    ----------http:\/\/tapi.xxxx.com\/t1\/doc\/index.html------------\n\/t1\/doc\/index.html\n\n----------http:\/\/tapi.xxxx.com\/t2\/doc\/index.html------------\n\/doc\/index.html\n\n----------http:\/\/tapi.xxxx.com\/t3\/doc\/index.html------------\n\/t3\/doc\/index.html\n\n----------http:\/\/tapi.xxxx.com\/t4\/doc\/index.html------------\n\/doc\/index.html\n\n----------http:\/\/tapi.xxxx.com\/t5\/doc\/index.html------------\n\/test\/doc\/index.html\n\n----------http:\/\/tapi.xxxx.com\/t6\/doc\/index.html------------\n\/testdoc\/index.html\n\n----------http:\/\/tapi.xxxx.com\/t7\/doc\/index.html------------\n\/test\/\/doc\/index.html\n\n----------http:\/\/tapi.xxxx.com\/t8\/doc\/index.html------------\n\/test\/doc\/index.html<\/pre>"}	
    	
    
    
    
    
    
    
    

    国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

    首頁 運(yùn)維 Nginx nginx location中uri的截取如何實(shí)現(xiàn)

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

    May 18, 2023 pm 12:07 PM
    nginx location uri

    說明:

    location 中的root 和alias

    • root 指令只是將搜尋的根設(shè)定為root 設(shè)定的目錄,即不會(huì)截?cái)鄒ri,而是使用原始uri 跳轉(zhuǎn)該目錄下查找文件

    • #aias 指令則會(huì)截?cái)嗥ヅ涞膗ri,然後使用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 &#39;{print $nf}&#39;
    /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 &#39;http://tapi.kaishustory.com/lctest5/&#39;
    curl &#39;http://tapi.kaishustory.com/lctest6/&#39;
    curl &#39;http://tapi.kaishustory.com/lctest7/&#39;
    結(jié)果都是 /data/web/index.html的輸出
    
    root@pts/1 $ curl &#39;http://tapi.kaishustory.com/lctest8/&#39;
    <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/; }  #含"//",截?cái)?location /t8 { proxy_pass http://servers/test; }  #正常,截?cái)?/pre>

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

    以上是nginx location中uri的截取如何實(shí)現(xiàn)的詳細(xì)內(nèi)容。更多資訊請(qǐng)關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

    本網(wǎng)站聲明
    本文內(nèi)容由網(wǎng)友自願(yuàn)投稿,版權(quán)歸原作者所有。本站不承擔(dān)相應(yīng)的法律責(zé)任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請(qǐng)聯(lián)絡(luò)admin@php.cn

    熱AI工具

    Undress AI Tool

    Undress AI Tool

    免費(fèi)脫衣圖片

    Undresser.AI Undress

    Undresser.AI Undress

    人工智慧驅(qū)動(dòng)的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

    AI Clothes Remover

    AI Clothes Remover

    用於從照片中去除衣服的線上人工智慧工具。

    Clothoff.io

    Clothoff.io

    AI脫衣器

    Video Face Swap

    Video Face Swap

    使用我們完全免費(fèi)的人工智慧換臉工具,輕鬆在任何影片中換臉!

    熱工具

    記事本++7.3.1

    記事本++7.3.1

    好用且免費(fèi)的程式碼編輯器

    SublimeText3漢化版

    SublimeText3漢化版

    中文版,非常好用

    禪工作室 13.0.1

    禪工作室 13.0.1

    強(qiáng)大的PHP整合開發(fā)環(huán)境

    Dreamweaver CS6

    Dreamweaver CS6

    視覺化網(wǎng)頁開發(fā)工具

    SublimeText3 Mac版

    SublimeText3 Mac版

    神級(jí)程式碼編輯軟體(SublimeText3)

    docker怎麼啟動(dòng)容器 docker怎麼啟動(dòng)容器 Apr 15, 2025 pm 12:27 PM

    Docker 容器啟動(dòng)步驟:拉取容器鏡像:運(yùn)行 "docker pull [鏡像名稱]"。創(chuàng)建容器:使用 "docker create [選項(xiàng)] [鏡像名稱] [命令和參數(shù)]"。啟動(dòng)容器:執(zhí)行 "docker start [容器名稱或 ID]"。檢查容器狀態(tài):通過 "docker ps" 驗(yàn)證容器是否正在運(yùn)行。

    docker容器名稱怎麼查 docker容器名稱怎麼查 Apr 15, 2025 pm 12:21 PM

    可以通過以下步驟查詢 Docker 容器名稱:列出所有容器(docker ps)。篩選容器列表(使用 grep 命令)。獲取容器名稱(位於 "NAMES" 列中)。

    怎麼查看nginx是否啟動(dòng) 怎麼查看nginx是否啟動(dòng) Apr 14, 2025 pm 01:03 PM

    確認(rèn) Nginx 是否啟動(dòng)的方法:1. 使用命令行:systemctl status nginx(Linux/Unix)、netstat -ano | findstr 80(Windows);2. 檢查端口 80 是否開放;3. 查看系統(tǒng)日誌中 Nginx 啟動(dòng)消息;4. 使用第三方工具,如 Nagios、Zabbix、Icinga。

    docker怎麼創(chuàng)建容器 docker怎麼創(chuàng)建容器 Apr 15, 2025 pm 12:18 PM

    在 Docker 中創(chuàng)建容器: 1. 拉取鏡像: docker pull [鏡像名] 2. 創(chuàng)建容器: docker run [選項(xiàng)] [鏡像名] [命令] 3. 啟動(dòng)容器: docker start [容器名]

    nginx怎麼啟動(dòng) nginx怎麼啟動(dòng) Apr 14, 2025 pm 01:06 PM

    問題:如何啟動(dòng) Nginx?答案:安裝 Nginx啟動(dòng) Nginx驗(yàn)證 Nginx 是否已啟動(dòng)探索其他啟動(dòng)選項(xiàng)自動(dòng)啟動(dòng) Nginx

    在Nginx和Apache之間進(jìn)行選擇:適合您的需求 在Nginx和Apache之間進(jìn)行選擇:適合您的需求 Apr 15, 2025 am 12:04 AM

    NGINX和Apache各有優(yōu)劣,適合不同場(chǎng)景。 1.NGINX適合高並發(fā)和低資源消耗場(chǎng)景。 2.Apache適合需要復(fù)雜配置和豐富模塊的場(chǎng)景。通過比較它們的核心特性、性能差異和最佳實(shí)踐,可以幫助你選擇最適合需求的服務(wù)器軟件。

    centos下phpstorm性能優(yōu)化方法 centos下phpstorm性能優(yōu)化方法 Apr 14, 2025 pm 05:30 PM

    提升CentOS系統(tǒng)下PhpStorm性能的實(shí)用技巧本文提供多種方法,幫助您優(yōu)化CentOS系統(tǒng)中PhpStorm的性能,從而提高開發(fā)效率。在實(shí)施任何優(yōu)化措施前,請(qǐng)務(wù)必備份重要數(shù)據(jù)并在測(cè)試環(huán)境中驗(yàn)證效果。一、系統(tǒng)級(jí)優(yōu)化精簡(jiǎn)系統(tǒng)服務(wù):禁用不必要的系統(tǒng)服務(wù)和守護(hù)進(jìn)程,減少系統(tǒng)資源占用。無界面模式:如果不需要圖形界面,切換到無界面模式可顯著節(jié)省資源。卸載冗余軟件:移除不再使用的軟件包和服務(wù),釋放系統(tǒng)資源。二、PHP配置優(yōu)化啟用OPcache:安裝并配置OPcache擴(kuò)展,顯

    NGINX與Apache:性能,可伸縮性和效率 NGINX與Apache:性能,可伸縮性和效率 Apr 19, 2025 am 12:05 AM

    NGINX和Apache都是強(qiáng)大的Web服務(wù)器,各自在性能、可擴(kuò)展性和效率上有獨(dú)特的優(yōu)勢(shì)和不足。 1)NGINX在處理靜態(tài)內(nèi)容和反向代理時(shí)表現(xiàn)出色,適合高並發(fā)場(chǎng)景。 2)Apache在處理動(dòng)態(tài)內(nèi)容時(shí)表現(xiàn)更好,適合需要豐富模塊支持的項(xiàng)目。選擇服務(wù)器應(yīng)根據(jù)項(xiàng)目需求和場(chǎng)景來決定。

    See all articles