In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the interception of uri in nginx location. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Description:
Root and alias in location
The root instruction simply sets the root of the search to the directory set by root, that is, it does not truncate uri, but uses the original uri to jump to find files in that directory.
The aias instruction truncates the matching uri and then uses the path set by alias plus the remaining uri as the subpath to find it.
Uri of proxy_pass in location
If the url of proxy_pass does not have uri
If the tail is "/", the matching uri will be truncated
If the tail is not "/", the matching uri will not be truncated
If the url of proxy_pass has uri, the matching uri will be truncated
Examples
Root in location
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;}
The curl test results are as follows
Note: if / is not added to the last face when entered by the browser, it will be filled automatically, but not curl
Root@pts/1$ curl http://tapi.xxxx.com/lctest/hello worldroot@pts/1$ curl http://tapi.xxxx.com/lctest2/hello world2root@pts/1$ curl http://tapi.xxxx.com/lctest3/3hello worldroot@pts/1$ curl http://tapi.xxxx.com/lctest4/hello world4
Location alias
Location / lctest5 {alias / data/web/;} location / lctest6/ {alias / data/web/;} location / lctest7 {alias / data/web;} # # 403 / data/web forbiddenlocation / lctest8/ {alias / data/web;}
The curl test results are as follows
Curl 'http://tapi.kaishustory.com/lctest5/'curl' http://tapi.kaishustory.com/lctest6/'curl 'http://tapi.kaishustory.com/lctest7/' result is the output of / data/web/index.html root@pts/1$ curl' http://tapi.kaishustory.com/lctest8/'403 Forbidden403 Forbiddennginx
Location proxy_pass
#-proxy_pass configuration-location / T1 / {proxy_pass http://servers;} # normal, not truncated location / T2 / {proxy_pass http://servers/;} # normal, truncated location / T3 {proxy_pass http://servers;} # normal, not truncated location / T4 {proxy_pass http://servers/; } # normal, truncated location / T5 / {proxy_pass http://servers/test/;} # normal, truncated location / T6 / {proxy_pass http://servers/test;} # missing "/", truncated location / T7 {proxy_pass http://servers/test/;} # containing "/ /", truncated location / T8 {proxy_pass http://servers/test;} # normal, truncated
Test script
For i in $(seq 8) do url= http://tapi.xxxx.com/t$i/doc/index.html echo "- $url-" curl urldone
Test result
-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 _ http://tapi.xxxx.com/t4/doc/index.html------------/doc/index.html----------http://tapi.xxxx.com/t5/doc/index.html------------/test/doc/index.html--------- _ 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 so much for sharing the interception of uri in nginx location. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.