-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
🔼 added $resolved_proto map #4262
base: develop
Are you sure you want to change the base?
Conversation
to ensure that the X-Forwarded-Proto and X-Forwarded-Scheme headers reflect the most accurate protocol. The resolved_proto variable prioritizes the X-Forwarded-Proto header (set by sources like Cloudflare or AWS) and falls back to $scheme when unavailable, then this value is used to set Scheme and Proto instead of $scheme
This is a beautiful example of a well written PR comment :) Thanks for looking into this - NPM was originally written with the concept that it would be the edge server and not behind another proxy. CI is currently failing with:
|
… should put it in `/docker/rootfs/etc/nginx/conf.d/include/resolved_proto_map.conf` instead.
Thank you very much :) one thing i do not understand is how this setting can effect my nginx config in laravel container for example if i manually set |
See this file which has the default location In order to override this, you'll have to define the entire
and in doing so, the host won't use the default |
@jc21 your last comment did not fix my problem (also won't cover http cases), but my PR hopefully will cover all cases, when do you have time to merge this, as for why check fail i have no idea what is casing the issue, so don't know how to fix it. right now i manually edit all my proxy conf files but reset or change will overwrite them ;( |
Improve Protocol Forwarding Accuracy Using
resolved_proto
This PR enhances the accuracy of protocol forwarding in Nginx Proxy Manager by introducing a
resolved_proto
map variable. Theresolved_proto
variable ensures that theX-Forwarded-Proto
andX-Forwarded-Scheme
headers consistently reflect the most authoritative protocol information, particularly in setups involving upstream proxies like Cloudflare or AWS.Context
While learning Nginx, I encountered an issue where protocol mismatches occurred in setups using Cloudflare's proxy feature, leading to errors in applications like Laravel. Specifically, in my case, Laravel's Livewire file upload feature failed with unauthorized errors when the
X-Forwarded-Proto
header was incorrectly set tohttp
instead ofhttps
.After investigating further, I discovered that the
proxy.conf
file in Nginx Proxy Manager always setsX-Forwarded-Proto
to$scheme
, which can conflict with the upstreamX-Forwarded-Proto
header set by proxies such as Cloudflare. This issue is compounded because these lines are automatically included in the default location block, leaving no way to override them through the UI.Changes in This PR
To address this issue:
A
resolved_proto
map is introduced:X-Forwarded-Proto
andX-Forwarded-Scheme
headers now use$resolved_proto
instead of$scheme
inproxy.conf
and_location.conf
.Benefits
X-Forwarded-Proto
andX-Forwarded-Scheme
headers correctly reflect the protocol information from upstream sources.Notes
This PR serves as a suggestion and might not cover every edge case, as I’m still learning Nginx. However, it addresses a common issue many users face, as documented in this discussion, and many more I saw in Laravel, Livewire or Filament issues while researching.
any feedback is welcome to refine the implementation further.