• notice
  • Congratulations on the launch of the Sought Tech site

The difference between adding a slash at the end of proxy_pass in Nginx

 In fact, the description of the title is not very accurate, to be precise:

When proxy_pass has a URI parameter, the part that matches the location in the user access path will be replaced with the URI part of proxy_pass.

When proxy_pass has no URI parameter, the URI remains unchanged, and the URI in the user access path is used directly.

   So what is a URI?

Nginx divides URL requests into domain name + port + URI, as shown in the following configuration:

location / user {
    proxy_pass http: // 127.0.0.1:8081/; }

Domain name: 127.0.0.1

Port: 8081

URI: /  (note that slashes count too)

 

Let's take a few examples to understand:

(1) User access path: http://192.168.0.1/user/getUser.do

location / user {
    proxy_pass http: // 127.0.0.1:8081; }

Actual access path: http://127.0.0.1:8081/user/getUser.do, the URI remains unchanged.

 

(2) User access path: http://192.168.0.1/user/getUser.do

location /user/ {
    proxy_pass http: // 127.0.0.1:8081; }

Actual access path: http://127.0.0.1:8081/user/getUser.do, the URI remains unchanged.

 

(3) User access path: http://192.168.0.1/user/getUser.do

location / user {
    proxy_pass http: // 127.0.0.1:8081/; }

Actual access path: http://127.0.0.1:8081//getUser.do, "/user" is replaced by "/".

 

(4) User access path: http://192.168.0.1/user/getUser.do

location /user/ {
    proxy_pass http: // 127.0.0.1:8081/; }

Actual access path: http://127.0.0.1:8081/getUser.do, "/user/" is replaced by "/".

 

(5) User access path: http://192.168.0.1/user/getUser.do

location / user {
    proxy_pass http: // 127.0.0.1:8081/data; }

Actual access path: http://127.0.0.1:8081/data/getUser.do, "/user" is replaced by "/data".

 

(6) User access path: http://192.168.0.1/user/info/getUser.do

location /user/ {
    proxy_pass http: // 127.0.0.1:8081/data; }

Actual access path: http://127.0.0.1:8081/datainfo/getUser.do, "/user/" is replaced by "/data".

 


Tags

Technical otaku

Sought technology together

Related Topic

1 Comments

author

oral atorvastatin 80mg & lt;a href="https://lipiws.top/"& gt;atorvastatin 10mg over the counter& lt;/a& gt; order lipitor 80mg online cheap

Jwpcxy

2024-03-07

Leave a Reply

+