What's the difference between nginx location and proxy_pass?
Most people don't understand the knowledge points of this article "What is the difference between nginx location and proxy_pass", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "What is the difference between nginx location and proxy_pass".
Pre-test access domain: www.test.com/api/upload
1. If location and proxy_pass both have/, then the real address does not have location matching directory location /api/ { proxy_pass http://127.0.0.1:8080/;}
Visit address: www.test.com/api/upload--> http://127.0.0.1:8080/upload
2.location without/, proxy_pass with/, real address with/location /api { proxy_pass http://127.0.0.1:8080/;}
Visit address: www.test.com/api/upload--> http://127.0.0.1:8080//upload
3.location with/, proxy_pass without/, then the real address will have location matching directory/api/location /api/ { proxy_pass http://127.0.0.1:8080;}
Visit address: www.test.com/api/upload--> http://127.0.0.1:8080/api/upload
4. If neither location nor proxy_pass carries/, the real address will carry location matching directory/api/location /api { proxy_pass http://127.0.0.1:8080;}
Visit address: www.test.com/api/upload--> http://127.0.0.1:8080/api/upload
5. Same as 1, but proxy_pass with address location /api/ { proxy_pass http://127.0.0.1:8080/server/;}
Visit address: www.test.com/api/upload--> http://127.0.0.1:8080/server/upload
6. The same as 2, but proxy_pass with address, then the real address will be multiple/location /api { proxy_pass http://127.0.0.1:8080/server/;}
Visit address: www.test.com/api/upload--> http://127.0.0.1:8080/server//upload
7. The same as 3, but proxy_pass with address, then the real address will be directly linked location /api/ { proxy_pass http://127.0.0.1:8080/server;}
Visit address: www.test.com/api/upload--> http://127.0.0.1:8080/serverupload
8. Same as 4, but proxy_pass has address, then real address matching address will replace location matching directory location /api { proxy_pass http://127.0.0.1:8080/server;}
Visit address: www.test.com/api/upload--> http://127.0.0.1:8080/server/upload
The above is about the content of this article about "what is the difference between nginx location and proxy_pass". I believe everyone has a certain understanding. I hope that the content shared by Xiaobian will be helpful to everyone. If you want to know more relevant knowledge, please pay attention to the industry information channel.