NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.83k stars 2.65k forks source link

Sending Underscores in your header NPM #3439

Open guibarbas opened 9 months ago

guibarbas commented 9 months ago

The bug NPM is causing problems with some software, such as Chatwoot, as it does not send Underscores in its header. However, I didn't identify any way to fix this via the interface.

This is a similar bug, however, with some differences: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1731

Nginx Proxy Manager Version v2.10.4

To Reproduce Steps to reproduce the behavior: Using Chatwoot as an example.

  1. Access Postman Create a GET request to the API:
  2. Add authorization of type: Api Key with the parameters: Key: api_access_token Value: YOUR_KEY Add to: Header
  3. See error

image

Expected behavior Return 200 with json payload

image

Additional context Below is what I receive in Chatwoot when I make a request to the API. The same error occurs when trying to connect the Evolution API to Chatwoot.

Chatwoot Log image I, [2024-01-08T20:45:37.526502 #1] INFO -- : source=rack-timeout id=ae362ea3-c711-4e4f-a35a-785f48f6e9bb timeout=15000ms state=ready I, [2024-01-08T20:45:37.527204 #1] INFO -- : [ae362ea3-c711-4e4f-a35a-785f48f6e9bb] Started GET "/api/v1/accounts/1/inboxes" for 10.0.0.2 at 2024-01-08 20:45:37 +0000 I, [2024-01-08T20:45:37.531310 #1] INFO -- : [ae362ea3-c711-4e4f-a35a-785f48f6e9bb] Processing by Api::V1::Accounts::InboxesController#index as JSON I, [2024-01-08T20:45:37.531415 #1] INFO -- : [ae362ea3-c711-4e4f-a35a-785f48f6e9bb] Parameters: {"account_id"=>"1"} I, [2024-01-08T20:45:37.532654 #1] INFO -- : [ae362ea3-c711-4e4f-a35a-785f48f6e9bb] Filter chain halted as :authenticate_user! rendered or redirected I, [2024-01-08T20:45:37.532852 #1] INFO -- : [ae362ea3-c711-4e4f-a35a-785f48f6e9bb] Completed 401 Unauthorized in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 361) I, [2024-01-08T20:45:37.533162 #1] INFO -- : source=rack-timeout id=ae362ea3-c711-4e4f-a35a-785f48f6e9bb timeout=15000ms service=7ms state=completed

Fix To fix the issue, the steps below were necessary.

1) Within the NPM panel, in the Proxy Host edition, activate the Websockets support function. image

2 ) In the Custom locations tab, we add a new location / and apply proxy_pass_request_headers on; image

So far, so good.

The problem with NPM starts here. 3) Access the server's FTP, and the folder where the hosts' records are located: In my case /var/lib/docker/volumes/proxy_data/_data/nginx/proxy_host

4) Access the registry corresponding to the host you want to modify and add: underscores_in_headers on; just below: listen [::]:443 ssl http2; image

5) Save and restart the NPM service

After that, the error no longer occurs. image

What do I want? It would be very important to be able to modify the header information directly via the interface, such as adding the item: underscores_in_headers on; Without needing to access the server via FTP. Because when this is done, any change we make to the NPM dashboard overwrites the file, erasing what we did.

Also, there is no need to restart the application to apply the correction.

Is this possible? Apply adjustments to Server { } directly via Dashboard, so we don't have to apply via FTP and lose it when we update the record?

And can we also apply adjustments globally to NPM via file or via Dashboard?

There are some adjustments that would be very interesting to be able to apply globally.

github-actions[bot] commented 3 months ago

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

afanjul commented 1 month ago

@guibarbas MANY MANY THANKS!!! you saved my day!!

guibarbas commented 1 month ago

@guibarbas MANY MANY THANKS!!! you saved my day!!

I'm happy to know that I was able to help in some way.

I hope the devs can adjust this in the future

afanjul commented 2 weeks ago

Hi @guibarbas, here are my 2 cents :D

According to NPM documentation, you can add server directives to all the proxy_hosts: https://nginxproxymanager.com/advanced-config/#custom-nginx-configurations

So just create a config "" file at /data/nginx/custom/server_proxy.conf with the nginx directive:

underscores_in_headers on;

and thats all, from now on you are sure that is applying to any proxy host, and moreover you can reset/save any host without losing that directive configuration.

In my case I didn't need the directive "proxy_pass_request_headers on;" to make it works... did you need it? could you check it without it?

regards

guibarbas commented 2 weeks ago

Hello @afanjul, Thank you very much for your feedback.

I'm using traefik now on my servers. But I will create a test environment and let you know.

afanjul commented 2 weeks ago

Hello @afanjul,

Thank you very much for your feedback.

I'm using traefik now on my servers.

But I will create a test environment and let you know.

Never mind, don't lose time. What's the differences you noticed between traefik and npm ? i'm using npm to act as a kind of NAT for http/ssh containers in my proxmox host.

is it traefik better ? thanks

guibarbas commented 2 weeks ago

Hello @afanjul, Thank you very much for your feedback. I'm using traefik now on my servers. But I will create a test environment and let you know.

Never mind, don't lose time. What's the differences you noticed between traefik and npm ? i'm using npm to act as a kind of NAT for http/ssh containers in my proxmox host.

is it traefik better ? thanks

I’ve noticed some key differences between Traefik and NPM.

Traefik is more complex, but it offers a lot of advanced features, especially for those who need dynamic routing. It can be a bit more challenging to configure, but since everything is set up directly in the application, it makes it easier to keep the environments functional and consistent.

On the other hand, NPM is super simple and straightforward. Its graphical interface makes it easy to use, especially for smaller setups where I just need a quick and uncomplicated reverse proxy. However, I’ve taken a break from using it due to the issues we discussed in this request.