302 error when nginx is doing reverse proxy

Phenomenon: When nginx uses a non-80 port as a reverse proxy, the browser access discovery returns a 302 error

Reason: proxy_set_header Host $host defined in proxy.conf file;

It means that nginx modifies the host information in the request header after receiving the browser request, and then forwards the request to the back-end real service node. After the service node responds, it transmits the returned information to nginx. The proxy, the back-end service node still thinks that nginx is port 80, so the response information is not correctly returned to the non-80 port of nginx

Solution: Change it to proxy_set_header Host $host:$server_port; just, change the host in the request header to the non-80 port of nginx, the back-end service node will know the correct nginx proxy port that should be returned in the response

{{o.name}}
{{m.name}}

Guess you like

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