Nginx proxy_pass URL end with and without slash / difference

In nginxthe configuration of proxy_passthe agent forwards:

  • In proxy_passthe back of the urlincrease /, in absolute root path.
  • In proxy_passthe latter urlwithout /indicating relative paths, path matching portion will also go to the proxy.

Assuming that access address is:http://localhost:8081/test/abc.html

  • Plus /:

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

    Actual visit url:http://127.0.0.1:8081/abc.html

  • Without /:

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

    Actual visit url:http://127.0.0.1:8081/test/abc.html

Published 212 original articles · won praise 151 · views 500 000 +

Guess you like

Origin blog.csdn.net/yhj19920417/article/details/83549763