When nginx configures proxy_pass, the difference between the URL with "/" at the end and without "/" at the end is as follows: Note: When location is a regular expression matching pattern, the URL in proxy_pass is not allowed to have a "/" at the end, so the regular expression matching pattern is not within the scope of discussion. When the URL in the proxy_pass configuration ends with a /, when nginx forwards, it will remove the location matching expression from the original URI and append it to the URL in proxy_pass. Test address: http://192.168.171.129/test/tes.jsp Scenario 1: location ^~ /test/ { proxy_pass http://192.168.171.129:8080/server/; } The actual access address after proxy: http://192.168.171.129:8080/server/tes.jsp Scenario 2: location ^~ /test { proxy_pass http://192.168.171.129:8080/server/; } The actual access address after proxy: http://192.168.171.129:8080/server//tes.jsp Scenario 3: location ^~ /test/ { proxy_pass http://192.168.171.129:8080/; } The actual access address after proxy: http://192.168.171.129:8080/tes.jsp Scenario 4: location ^~ /test { proxy_pass http://192.168.171.129:8080/; } The actual access address after proxy: http://192.168.171.129:8080//tes.jsp When there is no / at the end of the URL in the proxy_pass configuration, if the URL does not contain path, the original URI is directly concatenated after the URL in proxy_pass; if the URL contains path, the original URI is concatenated after removing the location matching expression and the URL in proxy_pass. Test address: http://192.168.171.129/test/tes.jsp Scenario 1: location ^~ /test/{ proxy_pass http://192.168.171.129:8080/server; } The actual access address after proxy: http://192.168.171.129:8080/servertes.jsp Scenario 2: location ^~ /test { proxy_pass http://192.168.171.129:8080/server; } The actual access address after proxy: http://192.168.171.129:8080/server/tes.jsp Scenario 3: location ^~ /test/ { proxy_pass http://192.168.171.129:8080; } The actual access address after proxy: http://192.168.171.129:8080/test/tes.jsp Scenario 4: location ^~ /test { proxy_pass http://192.168.171.129:8080; } The actual access address after proxy: http://192.168.171.129:8080/test/tes.jsp This concludes this article on the differences between nginx proxy_pass with and without the end of the URL. For more information about the end of the nginx proxy_pass URL, please search 123WORDPRESS.COM's previous articles or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of Object.create instance usage in js
>>: In-depth understanding of HTML form input monitoring
When using MySQL, many developers often perform f...
Resume Code: XML/HTML CodeCopy content to clipboa...
If you upgrade in a formal environment, please ba...
Docker Overview Docker is an open source software...
This note is an installation tutorial. It has no ...
transform:scale() can achieve proportional zoomin...
Today's web designs tend to display very larg...
Table of contents 1. Test environment 1.1 Install...
The functions of the three attributes flex-grow, ...
This article introduces the sample code of CSS3 t...
1. Install less dependency: npm install less less...
background Now the company's projects are dev...
High CPU load caused by MySQL This afternoon, I d...
Table of contents 1. this points to 2. Modify thi...
How to use the code in NetEase Blog: First log in...