Skip to content

www/nginx: make upstream client-address headers configurable - #5685

Open
EyJunge1 wants to merge 2 commits into
opnsense:masterfrom
EyJunge1:nginx/client-address-headers-5684
Open

www/nginx: make upstream client-address headers configurable#5685
EyJunge1 wants to merge 2 commits into
opnsense:masterfrom
EyJunge1:nginx/client-address-headers-5684

Conversation

@EyJunge1

Copy link
Copy Markdown

Important notices

Before you submit a pull request, we ask you kindly to acknowledge the following:

If AI was used, please disclose:

  • Model used: Cursor Grok 4.5
  • Extent of AI involvement: Assisted with implementation planning, model/form/template edits for the new Upstream options, and drafting this pull request text. Changes were reviewed and adjusted by the author.

Describe the problem

The www/nginx plugin hardcodes upstream client-address headers in location.conf (X-Real-IP, X-Forwarded-For via $proxy_add_x_forwarded_for, etc.). There is no GUI option to change or disable X-Forwarded-For, no control over RFC 7239 Forwarded, and provider headers such as CF-Connecting-IP / True-Client-IP are passed through unchanged.

With trusted proxies and real_ip_header, $remote_addr is the validated client address, but $proxy_add_x_forwarded_for can still preserve a client-supplied chain, and an unsanitized Forwarded header can be preferred by backends over X-Real-IP. Existing include hooks cannot safely replace these location-level proxy_set_header directives without duplicates.


Describe the proposed solution

Add Upstream advanced options next to the existing x_forwarded_host_verbatim setting:

  • XFF: Mode — Append (default), Replace ($remote_addr), or Drop
  • Forwarded: Mode — Preserve (default), Replace (sanitized RFC 7239 from $remote_addr + $scheme), or Drop
  • Suppress CF-/True-Client-IP — clear those headers before proxying

Defaults keep the current behavior. Generated config emits at most one proxy_set_header per header name. RFC 7239 maps are only generated when an upstream uses Forwarded Replace.


Related issue

#5684

Allow X-Forwarded-For, Forwarded, and provider client-IP headers to be
sanitized at the upstream so nginx can act as a strict trust boundary.
Shorten upstream help text to match existing style and emit the
Forwarded RFC 7239 maps only when an upstream uses Replace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant