Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Nginx Configuration - proxy_set_header Host #1003

Open
DaFlowah opened this issue Apr 8, 2021 · 13 comments
Open

Custom Nginx Configuration - proxy_set_header Host #1003

DaFlowah opened this issue Apr 8, 2021 · 13 comments
Labels

Comments

@DaFlowah
Copy link

DaFlowah commented Apr 8, 2021

Describe the bug
Hi, I need to override the default proxy_set_header Host $host to proxy_set_header Host $http_host for a specific Proxy Host, since it's required by the app I'm trying to Proxy (more info here)

To Reproduce
Create a Proxy Host
Go to Advanced and add proxy_set_header Host $http_host;
The value is not applied and the application throws an error.

Expected behavior
I am expecting this value to be added.

Screenshots
immagine

Operating System

  • Nginx Proxy Manager on Home Assistant OS running on Pi4

Additional context
If on the host I edit /etc/nginx/conf.d/include/proxy.conf and change the default value, it works, but it's a temporary change.

@DaFlowah DaFlowah added the bug label Apr 8, 2021
@ananiasfilho
Copy link

ananiasfilho commented Jul 4, 2021

Any update? I have same issue running flask and odoo behind NPM. I cant see client IP and others headers

@Nate-09
Copy link

Nate-09 commented Jul 27, 2021

Same here, got the same issue with another docker image running remotely.one. I'm also having additional issues with NPM not setting additional configuration under the custom config, wondering if this is an issue with the custom configuration in UI itself.

I've tried to also set additional header info as seen below but when I test for the CSP - these come back as fail from external testing on top of the Client IP and other headers

add_header Content-Security-Policy "upgrade-insecure-requests";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy no-referrer always;
add_header X-Robots-Tag none;
proxy_hide_header Upgrade;
proxy_hide_header X-Powered-By;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

@netstx
Copy link

netstx commented Aug 26, 2022

There's a warning about this right underneath the text box where you add these custom configs:

Please note, that any add_header or set_header directives added here will not be used by nginx. You will have to add a custom location '/' and add the header in the custom config there.

@a18ccms
Copy link

a18ccms commented Oct 25, 2022

add a custom location '/' and add the header in the custom config :proxy_set_header Host $http_host;
web is 400 Bad Request

bash-5.1# pwd
/data/nginx/proxy_host
bash-5.1# cat 12.conf 
# ------------------------------------------------------------
# xxx.xxx.xxx
# ------------------------------------------------------------


server {
  set $forward_scheme http;
  set $server         "192.168.2.19";
  set $port           8806;

  listen 8080;
listen [::]:8080;

listen 4443 ssl http2;
listen [::]:4443 ssl http2;


  server_name xxx.xxx.xxx;


  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-3/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-3/privkey.pem;


proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;


  access_log /data/logs/proxy-host-12_access.log proxy;
  error_log /data/logs/proxy-host-12_error.log warn;

  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       http://192.168.2.19:8806;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;
    
    proxy_set_header Host $http_host;

  }


  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}

@jschlatow
Copy link

I have walked the same road when I just noticed that a possible solution has been suggested in #1477.

@GAS85
Copy link

GAS85 commented Feb 21, 2023

Basically you have to edit /data/nginx/custom/server_proxy.conf that is designed for such a changes.
I agree that UI management should be add here. As also that those settings are common for all proxies that you will create.

P.S. you do not need to set add_header X-Frame-Options "SAMEORIGIN"; this could be managed via Docker Envs.

Copy link

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

@github-actions github-actions bot added the stale label Mar 14, 2024
@GAS85
Copy link

GAS85 commented Mar 14, 2024

👍

1 similar comment
@jschlatow
Copy link

👍

@github-actions github-actions bot removed the stale label May 14, 2024
@whc2001
Copy link

whc2001 commented Jul 6, 2024

I think even adding the config into custom location won't work, since the directives will be added above the default config and get overriden

image

@ConfidentKeyboard
Copy link

I've tried everything here, and it still doesn't seem to work. On Unraid with nginx-proxy-manager-official. Any suggestions?

@whc2001
Copy link

whc2001 commented Oct 17, 2024

I've tried everything here, and it still doesn't seem to work. On Unraid with nginx-proxy-manager-official. Any suggestions?

Someone pushed a bugged commit which broke the behaviour of custom directions. You need to edit the config file in data dir and never touch the WebUI again.

@ConfidentKeyboard
Copy link

I've tried everything here, and it still doesn't seem to work. On Unraid with nginx-proxy-manager-official. Any suggestions?

Someone pushed a bugged commit which broke the behaviour of custom directions. You need to edit the config file in data dir and never touch the WebUI again.

I assume an update would then overwrite any changes I make as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants