nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

Host should be $proxy_host, not $host

Open vbraun opened this issue 2 years ago • 5 comments

  • $host is the Host sent by the user's browser. This is the correct setting if the service has built-in support for being proxied.

  • $proxy_host is the Host as if the browser would run on the proxy. This is the correct setting if the service does not have built-in support for reverse proxies. It is also the nginx default.

  • In nginx, you cannot unset the Host header. Configuring headers multiple times just sends multiple values with the http request. So there is no way to "fix" the Host by adding a custom header if it is already set.

For these reasons, Host should not be set (and default to $proxy_host). In the unlikely case that your service needs something else you can then just set a custom Host header in the GUI.

Fixes https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2675

vbraun avatar Oct 08 '23 11:10 vbraun

PR is now considered stale. If you want to keep it open, please comment :+1:

github-actions[bot] avatar May 31 '24 01:05 github-actions[bot]

How is this STILL not merged? Such a design flaw just obliterates all the usefulness this program brought. PLEASE MERGE THIS and let's have it fixed at last.

valinet avatar Jul 23 '24 00:07 valinet

more_set_input_headers 'Host: www.domain-new.com';

Integerated nginx is openresty, that support "headers-more-nginx-module-0.37" modules.

so, you can reset the input header by command : more_set_input_headers

================

set input headers

location /foo { set $my_host 'my dog'; more_set_input_headers 'Host: $my_host'; more_set_input_headers -t 'text/plain' 'X-Foo: bah';

 # now $host and $http_host have their new values...
 # ...

}

kvchoi avatar Dec 05 '24 12:12 kvchoi

more_set_input_headers 'Host: www.domain-new.com'; ... so, you can reset the input header by command : more_set_input_headers

Not sure I understand how more_set_input_headers helps here. It looks like any custom headers I write, including more_set_input_headers, will appear in the generated conf file before the generated proxy_set_header Host $host; line. So are you saying more_set_input_headers takes precedence over any proxy_set_header statements, even if it appears before such statements?

KevinMitchell avatar May 02 '25 18:05 KevinMitchell

Docker Image for build 5 is available on DockerHub:

nginxproxymanager/nginx-proxy-manager-dev:pr-3247

[!NOTE] Ensure you backup your NPM instance before testing this image! Especially if there are database changes. This is a different docker image namespace than the official image.

[!WARNING] Changes and additions to DNS Providers require verification by at least 2 members of the community!