[GH-ISSUE #2076] proxy_set_header Host duplicates in the location #1497

Closed
opened 2026-02-26 07:31:18 +03:00 by kerem · 10 comments
Owner

Originally created by @Treverr on GitHub (May 28, 2022).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2076

I have a use case where I am proxying from my server to another hosted website. I found an issue where npm adds the proxy_set_header Host $host automatically, and I cannot override it manually, which I need to in this case because the $host is wrong and I needed to manually set it to the upstream host for CDN's to recognize it. $host is not defined so its null

I tried to do set $host in advanced but it just took my proxy offline.

For example, I need it to look like this:

  location / {
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP		$remote_addr;
    proxy_pass       https://trever.mystrikingly.com:443;

    # Asset Caching
  include conf.d/include/assets.conf;

    # Force SSL
    include conf.d/include/force-ssl.conf;
    proxy_set_header Host "trever.mystrikingly.com";
  }

but NPM does not let that happen, it makes the configuration like this:

  location / {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP		$remote_addr;
    proxy_pass       https://trever.mystrikingly.com:443;

    # Asset Caching
  include conf.d/include/assets.conf;

    # Force SSL
    include conf.d/include/force-ssl.conf;
    proxy_set_header Host "trever.mystrikingly.com";
  }

Which does not work upstream.

Originally created by @Treverr on GitHub (May 28, 2022). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2076 I have a use case where I am proxying from my server to another hosted website. I found an issue where npm adds the `proxy_set_header Host $host` automatically, and I cannot override it manually, which I need to in this case because the $host is wrong and I needed to manually set it to the upstream host for CDN's to recognize it. `$host` is not defined so its null I tried to do `set $host` in advanced but it just took my proxy offline. For example, I need it to look like this: ``` location / { proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_pass https://trever.mystrikingly.com:443; # Asset Caching include conf.d/include/assets.conf; # Force SSL include conf.d/include/force-ssl.conf; proxy_set_header Host "trever.mystrikingly.com"; } ``` but NPM does not let that happen, it makes the configuration like this: ``` location / { proxy_set_header Host $host; proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_pass https://trever.mystrikingly.com:443; # Asset Caching include conf.d/include/assets.conf; # Force SSL include conf.d/include/force-ssl.conf; proxy_set_header Host "trever.mystrikingly.com"; } ``` Which does not work upstream.
kerem 2026-02-26 07:31:18 +03:00
  • closed this issue
  • added the
    stale
    label
Author
Owner

@pluigim commented on GitHub (Jun 2, 2022):

Hi have your same problem !

I have some host that don't work if you don't set
proxy_set_header Host

with the called fqdn hostname.

Have you found any solution ?

<!-- gh-comment-id:1144806378 --> @pluigim commented on GitHub (Jun 2, 2022): Hi have your same problem ! I have some host that don't work if you don't set proxy_set_header Host with the called fqdn hostname. Have you found any solution ?
Author
Owner

@Treverr commented on GitHub (Jun 2, 2022):

I had to manually go in and edit to remove that $host line that NPM adds only keeping my custom one.

Depending on your set up, You'll need to go into the docker itself 'docker exec -it nginsproxymanager sh' and and navigate to '/data/.../proxy_hosts' and edit the item manually.

<!-- gh-comment-id:1144975186 --> @Treverr commented on GitHub (Jun 2, 2022): I had to manually go in and edit to remove that $host line that NPM adds only keeping my custom one. Depending on your set up, You'll need to go into the docker itself 'docker exec -it nginsproxymanager sh' and and navigate to '/data/.../proxy_hosts' and edit the item manually.
Author
Owner

@pluigim commented on GitHub (Jun 4, 2022):

Hi !

What you suggested solved the problem !

Thanks

<!-- gh-comment-id:1146556813 --> @pluigim commented on GitHub (Jun 4, 2022): Hi ! What you suggested solved the problem ! Thanks
Author
Owner

@prashantsomashekar commented on GitHub (Oct 31, 2022):

@jc21 Is there no way to override this line, without resorting to this?

<!-- gh-comment-id:1297770673 --> @prashantsomashekar commented on GitHub (Oct 31, 2022): @jc21 Is there no way to override this line, without resorting to this?
Author
Owner

@cromulus commented on GitHub (Nov 17, 2022):

same issue. Trying to proxy s3 through NPM and having this issue.

Thanks!

<!-- gh-comment-id:1318788045 --> @cromulus commented on GitHub (Nov 17, 2022): same issue. Trying to proxy s3 through NPM and having this issue. Thanks!
Author
Owner

@amjkwd commented on GitHub (May 19, 2023):

Hi, there,
I had found a way to solve that.
You can delete all your custom location in custom location tab, and add all location code in the advance tab.
It works for me to add my 'proxy_set_header Host xxxxxxx', hope you too.

<!-- gh-comment-id:1553988175 --> @amjkwd commented on GitHub (May 19, 2023): Hi, there, I had found a way to solve that. You can delete all your custom location in custom location tab, and add all location code in the advance tab. It works for me to add my 'proxy_set_header Host xxxxxxx', hope you too.
Author
Owner

@github-actions[bot] commented on GitHub (Feb 16, 2024):

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

<!-- gh-comment-id:1947634546 --> @github-actions[bot] commented on GitHub (Feb 16, 2024): Issue is now considered stale. If you want to keep it open, please comment :+1:
Author
Owner

@bilogic commented on GitHub (Apr 22, 2024):

For posterity due to the complete lack of documentation of NPM:

  1. In Details, use http, 0.0.0.0, 80 to show that settings on this page have no effect
  2. In Advanced, set
    location / {
        proxy_pass "https://source.com";
        proxy_set_header Host "source.com";
    }
    
<!-- gh-comment-id:2068581644 --> @bilogic commented on GitHub (Apr 22, 2024): For posterity due to the complete lack of documentation of NPM: 1. In `Details`, use `http`, `0.0.0.0`, `80` to show that settings on this page have no effect 2. In `Advanced`, set ``` location / { proxy_pass "https://source.com"; proxy_set_header Host "source.com"; } ```
Author
Owner

@github-actions[bot] commented on GitHub (Nov 25, 2024):

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

<!-- gh-comment-id:2496529943 --> @github-actions[bot] commented on GitHub (Nov 25, 2024): Issue is now considered stale. If you want to keep it open, please comment :+1:
Author
Owner

@github-actions[bot] commented on GitHub (Dec 4, 2025):

Issue was closed due to inactivity.

<!-- gh-comment-id:3609690969 --> @github-actions[bot] commented on GitHub (Dec 4, 2025): Issue was closed due to inactivity.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#1497
No description provided.