After nginx reverse proxy, the problem of getting hostname is incorrect

After the reverse proxy is configured on nginx, the hostname of the proxied host obtained by viewing the serverName of the request on the proxied host is not the hostname of the user's original request. To solve this problem, the following configuration is required (assuming the path of the reverse proxy is / and the real access address is http://localhost:8080):

location / {
            proxy_pass   http://localhost:8080;
			proxy_set_header HOST $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

 

If there is no proxy_set_header configuration, the hostname obtained on the proxy host is localhost:8080, not the hostname of the user's original request.

Guess you like

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