illustrate: Root and alias in location
The uri of the proxy_pass in location If the proxy_pass url does not contain uri
If the proxy_pass url has a 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/lctest4 location /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 you don't add a / at the end when you enter it in the browser, it will be automatically added, but curl will not 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; } 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/' The results are all /data/web/index.html output 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 configuration--------------------- location /t1/ { proxy_pass http://servers; } #Normal, not truncated location /t2/ { proxy_pass http://servers/; } #Normal, truncation location /t3 { proxy_pass http://servers; } #Normal, not truncated location /t4 { proxy_pass http://servers/; } #Normal, truncation location /t5/ { proxy_pass http://servers/test/; } #Normal, truncation location /t6/ { proxy_pass http://servers/test; } #Missing "/", truncation location /t7 { proxy_pass http://servers/test/; } #Contains "//", truncation location /t8 { proxy_pass http://servers/test; } #Normal, truncation Test Scripts for i in $(seq 8) do url=http://tapi.xxxx.com/t$i/doc/index.html echo "----------$url-----------" curl url done Test Results ----------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 The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: mysql workbench installation and configuration tutorial under centOS
>>: JavaScript type detection method example tutorial
There are many database management tools for MySQ...
This article example shares the specific code of ...
Aggregate functions Acts on a set of data and ret...
content Use scaffolding to quickly build a node p...
Shopify Plus is the enterprise version of the e-c...
MySQL Introduction to MySQL MySQL was originally ...
This article mainly explains how to install the M...
Table of contents 1. Introduction II. Monitoring ...
This article shares the specific code of Vue to i...
The code can be further streamlined, but due to t...
Table of contents Docker image download Start mys...
Apple Mug Icons and Extras HD StorageBox – add on...
Regular expressions are often used to search and ...
Search Mirror docker search rocketmq View image v...
Preface The role of process management: Determine...