The pit of nginx: automatic jump with port number (memo)

Description of the problem:

When nginx is reverse proxying, the request url does not have a tail / there will be an unexpected jump, and nginx will redirect to the location/path with a tail / by default.

The pit here is: if the server has a listen port, the automatic jump will be Bring this port, in case there is a layer of reverse proxy in front, there will be an accident.

Solution:
1. The front-level reverse proxy is a field without a port number such as a domain name, directly configure port_in_redirect off

2. The front-level reverse proxy is another port, which is embarrassing, you need to configure proxy_pass and redirect manually
location = /xx/ {}
location = /xx {proxy_pass: http://{yours} }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326307806&siteId=291194637