1. <mark id="9glrl"><em id="9glrl"></em></mark>
        <ol id="9glrl"><strong id="9glrl"></strong></ol>

        \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; }  #正常,不截斷\nlocation \/t2\/ { proxy_pass http:\/\/servers\/; }  #正常,截斷\nlocation \/t3 { proxy_pass http:\/\/servers; }  #正常,不截斷\nlocation \/t4 { proxy_pass http:\/\/servers\/; }  #正常,截斷\nlocation \/t5\/ { proxy_pass http:\/\/servers\/test\/; }  #正常,截斷\nlocation \/t6\/ { proxy_pass http:\/\/servers\/test; }  #缺\"\/\",截斷\nlocation \/t7 { proxy_pass http:\/\/servers\/test\/; }  #含\"\/\/\",截斷\nlocation \/t8 { proxy_pass http:\/\/servers\/test; }  #正常,截斷<\/pre>

        測試腳本<\/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>

        測試結(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成人天堂

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

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

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

        說明:

        location 中的 root 和 alias

        • root 指令只是將搜索的根設置為 root 設定的目錄,即不會截斷 uri,而是使用原始 uri 跳轉(zhuǎn)該目錄下查找文件

        • aias 指令則會截斷匹配的 uri,然后使用 alias 設定的路徑加上剩余的 uri 作為子路徑進行查找

        location 中的 proxy_pass 的 uri

        如果 proxy_pass 的 url 不帶 uri

        • 如果尾部是"/",則會截斷匹配的uri

        • 如果尾部不是"/",則不會截斷匹配的uri

        如果proxy_pass的url帶uri,則會截斷匹配的uri

        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 測試結(jié)果如下

        備注: 瀏覽器輸入的時候最后面不添加 / , 會自動補上,但是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 測試結(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; }  #正常,不截斷
        location /t2/ { proxy_pass http://servers/; }  #正常,截斷
        location /t3 { proxy_pass http://servers; }  #正常,不截斷
        location /t4 { proxy_pass http://servers/; }  #正常,截斷
        location /t5/ { proxy_pass http://servers/test/; }  #正常,截斷
        location /t6/ { proxy_pass http://servers/test; }  #缺"/",截斷
        location /t7 { proxy_pass http://servers/test/; }  #含"//",截斷
        location /t8 { proxy_pass http://servers/test; }  #正常,截斷

        測試腳本

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

        測試結(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的截取如何實現(xiàn)的詳細內(nèi)容。更多信息請關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

        本站聲明
        本文內(nèi)容由網(wǎng)友自發(fā)貢獻,版權(quán)歸原作者所有,本站不承擔相應法律責任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請聯(lián)系admin@php.cn

        熱AI工具

        Undress AI Tool

        Undress AI Tool

        免費脫衣服圖片

        Undresser.AI Undress

        Undresser.AI Undress

        人工智能驅(qū)動的應用程序,用于創(chuàng)建逼真的裸體照片

        AI Clothes Remover

        AI Clothes Remover

        用于從照片中去除衣服的在線人工智能工具。

        Clothoff.io

        Clothoff.io

        AI脫衣機

        Video Face Swap

        Video Face Swap

        使用我們完全免費的人工智能換臉工具輕松在任何視頻中換臉!

        熱工具

        記事本++7.3.1

        記事本++7.3.1

        好用且免費的代碼編輯器

        SublimeText3漢化版

        SublimeText3漢化版

        中文版,非常好用

        禪工作室 13.0.1

        禪工作室 13.0.1

        功能強大的PHP集成開發(fā)環(huán)境

        Dreamweaver CS6

        Dreamweaver CS6

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

        SublimeText3 Mac版

        SublimeText3 Mac版

        神級代碼編輯軟件(SublimeText3)

        docker怎么啟動容器 docker怎么啟動容器 Apr 15, 2025 pm 12:27 PM

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

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

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

        怎么查看nginx是否啟動 怎么查看nginx是否啟動 Apr 14, 2025 pm 01:03 PM

        確認 Nginx 是否啟動的方法:1. 使用命令行:systemctl status nginx(Linux/Unix)、netstat -ano | findstr 80(Windows);2. 檢查端口 80 是否開放;3. 查看系統(tǒng)日志中 Nginx 啟動消息;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 [選項] [鏡像名] [命令] 3. 啟動容器: docker start [容器名]

        nginx怎么啟動 nginx怎么啟動 Apr 14, 2025 pm 01:06 PM

        問題:如何啟動 Nginx?答案:安裝 Nginx啟動 Nginx驗證 Nginx 是否已啟動探索其他啟動選項自動啟動 Nginx

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

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

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

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

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

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

        See all articles