[GH-ISSUE #2896] Response headers duplicate when using the add_header nginx config #1985

Open
opened 2026-02-26 07:33:34 +03:00 by kerem · 4 comments
Owner

Originally created by @nickelswitte on GitHub (May 7, 2023).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2896

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • Yes
  • Are you sure you're not using someone else's docker image?
    • Yes
  • Have you searched for similar issues (both open and closed)?
    • Yes

Describe the bug

When adding headers to the response via the advanced custom nginx configuration, the headers are duplicated in the response, rather than overwritten or appended, resulting in unusual behaviour.

Nginx Proxy Manager Version

2.10.2

To Reproduce
Steps to reproduce the behavior:

  1. Set the following inside the custom nginx config, as found in this issue #1183
location / {
  # Force SSL
  include conf.d/include/force-ssl.conf;
  # HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
  add_header Strict-Transport-Security "max-age=63072000;includeSubDomains; preload" always;
  add_header X-Frame-Options "ALLOW-FROM my.domain.tld";
  add_header Content-Security-Policy "frame-ancestors my.domain.tld";
  # Proxy!
  include conf.d/include/proxy.conf;
}
  1. Load the page and inspect the response in the browser:
HTTP/2 200 OK
server: openresty
date: Sun, 07 May 2023 10:32:39 GMT
content-type: text/html
content-encoding: gzip
x-frame-options: sameorigin #DUPLICATE
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
content-security-policy: default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; manifest-src 'self'; media-src 'self' blob:; child-src 'self' blob:; frame-src 'self'; frame-ancestors 'none' #DUPLICATE
referrer-policy: same-origin
permissions-policy: interest-cohort=()
x-frame-options: ALLOW-FROM my.domain.tld #DUPLICATE
content-security-policy: frame-ancestors my.domain.tld #DUPLICATE
X-Firefox-Spdy: h2

Expected behavior

That the header will be appended or replaced, or rather generally, that the browser will accept the duplicate header in some way.

Originally created by @nickelswitte on GitHub (May 7, 2023). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2896 <!-- Are you in the right place? - If you are looking for support on how to get your upstream server forwarding, please consider asking the community on Reddit. - If you are writing code changes to contribute and need to ask about the internals of the software, Gitter is the best place to ask. - If you think you found a bug with NPM (not Nginx, or your upstream server or MySql) then you are in the *right place.* --> **Checklist** - Have you pulled and found the error with `jc21/nginx-proxy-manager:latest` docker image? - Yes - Are you sure you're not using someone else's docker image? - Yes - Have you searched for similar issues (both open and closed)? - Yes **Describe the bug** <!-- A clear and concise description of what the bug is. --> When adding headers to the response via the _advanced custom nginx configuration_, the headers are duplicated in the response, rather than overwritten or appended, resulting in unusual behaviour. **Nginx Proxy Manager Version** <!-- What version of Nginx Proxy Manager is reported on the login page? --> 2.10.2 **To Reproduce** Steps to reproduce the behavior: 1. Set the following inside the custom nginx config, as found in this issue #1183 ``` location / { # Force SSL include conf.d/include/force-ssl.conf; # HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years) add_header Strict-Transport-Security "max-age=63072000;includeSubDomains; preload" always; add_header X-Frame-Options "ALLOW-FROM my.domain.tld"; add_header Content-Security-Policy "frame-ancestors my.domain.tld"; # Proxy! include conf.d/include/proxy.conf; } ``` 2. Load the page and inspect the response in the browser: ``` HTTP/2 200 OK server: openresty date: Sun, 07 May 2023 10:32:39 GMT content-type: text/html content-encoding: gzip x-frame-options: sameorigin #DUPLICATE x-xss-protection: 1; mode=block x-content-type-options: nosniff content-security-policy: default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; manifest-src 'self'; media-src 'self' blob:; child-src 'self' blob:; frame-src 'self'; frame-ancestors 'none' #DUPLICATE referrer-policy: same-origin permissions-policy: interest-cohort=() x-frame-options: ALLOW-FROM my.domain.tld #DUPLICATE content-security-policy: frame-ancestors my.domain.tld #DUPLICATE X-Firefox-Spdy: h2 ``` **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> That the header will be appended or replaced, or rather generally, that the browser will accept the duplicate header in some way.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2024):

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

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

@nickelswitte commented on GitHub (Feb 23, 2024):

I am still interested in an response on this

<!-- gh-comment-id:1961211438 --> @nickelswitte commented on GitHub (Feb 23, 2024): I am still interested in an response on this
Author
Owner

@dhruvb14 commented on GitHub (Oct 26, 2024):

I got this working finally in NPM

The magic is proxy_hide_header X-Frame-Options;

I added that to the top with the other headers and nothing in advanced tab just in the location > advanced tab

Screenshot 2024-10-26 at 12 00 37 PM
<!-- gh-comment-id:2439632572 --> @dhruvb14 commented on GitHub (Oct 26, 2024): I got this working finally in NPM The magic is `proxy_hide_header X-Frame-Options;` I added that to the top with the other headers and nothing in advanced tab just in the `location` > `advanced` tab <img width="509" alt="Screenshot 2024-10-26 at 12 00 37 PM" src="https://github.com/user-attachments/assets/20e57ebc-460d-4441-85f2-f96c08812a0a">
Author
Owner

@github-actions[bot] commented on GitHub (Jun 9, 2025):

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

<!-- gh-comment-id:2954463052 --> @github-actions[bot] commented on GitHub (Jun 9, 2025): Issue is now considered stale. If you want to keep it open, please comment :+1:
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#1985
No description provided.