Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.