Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is proxy_set_header Host $host; no longer working in nginx 1.8.0?

Tags:

nginx

proxy

I used proxy_set_header Host $host; to set the host header to the original request host. In nginx 1.4.1 this was working fine. Now after upgrading to 1.8.0, I'm getting the local IP instead of the host passed by the browser.

Why did this happen and how do I fix it?

like image 551
iwein Avatar asked Jul 17 '15 18:07

iwein


People also ask

What is Proxy_set_header Nginx?

To adjust or set headers for proxied connections, use the proxy_set_header directive, followed by the header value. You can find a list of all available Request Headers and their allowed values here . If you want to prevent a header from being passed to the proxied server, set it to an empty string "" .

What is proxy pass in nginx?

The proxy_pass setting makes the Nginx reverse proxy setup work. The proxy_pass is configured in the location section of any virtual host configuration file. To set up an Nginx proxy_pass globally, edit the default file in Nginx's sites-available folder.


1 Answers

Use proxy_set_header Host $http_host.

If proxy_set_header Host $host; no longer works, perhaps the meaning/ behavior of $host changed. $http_host just passes along what was sent by the browser.

like image 73
gucki Avatar answered Nov 03 '22 07:11

gucki