Skip to content

Conversation

@vbraun
Copy link

@vbraun vbraun commented Oct 8, 2023

  • $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 #2675

* $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 the header in the GUI.

Fixes NginxProxyManager#2675
@jc21 jc21 added the requires-verification Waiting for one or more people to confirm the fix label Nov 22, 2023
@github-actions
Copy link

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

@github-actions github-actions bot added the stale label May 31, 2024
@valinet
Copy link

valinet commented Jul 23, 2024

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.

@github-actions github-actions bot removed the stale label Sep 10, 2024
@kvchoi
Copy link

kvchoi commented Dec 5, 2024

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...
 # ...

}

@KevinMitchell
Copy link

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?

@nginxproxymanagerci
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires-verification Waiting for one or more people to confirm the fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot proxy to sites that require a correct Host header

5 participants