www/nginx: add hostnames; and proxy_protocol on; options for SNI upstream mapping - #5655
Open
muchachagrande wants to merge 2 commits into
Open
Conversation
…ream mapping Closes opnsense#5596
Member
|
Hi! I'd probably just clarify the help for snihostname.enable_hostnames (to more closely match the nginx docs), something like: "Indicates that source values can be hostnames with a prefix or suffix mask, e.g. .example.com, www.example., or .example.com." |
kulikov-a
approved these changes
Aug 23, 2026
Author
|
Thanks! Updated the help text for Separate question: since this PR adds two new model fields |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Important notices
Before you submit a pull request, we ask you kindly to acknowledge the following:
If AI was used, please disclose:
Describe the problem
The SNI Upstream Mapping feature generates an nginx
map {}block and aproxy_pass $hostmap...;directive, but two related nginx directives were not exposed in the GUI:hostnames;inside the generatedmap {}block, required for wildcard(
*.example.com,www.example.*) or dot-prefixed (.example.com) mapkeys — and for regular expressions (
~...,~*...) — to actually beinterpreted as patterns instead of literal strings. Without it, entries
using this syntax are silently accepted by the GUI but never match
anything at runtime.
proxy_protocol on;inside the server {} block, to forward the client's realaddress to the backend selected via the SNI map. This was already possible
for a fixed "Upstream", but not when routing dynamically via SNI Upstream
Mapping.
The
hostnamefield on each map entry was also a plainHostnameField, which rejects the wildcard/regex/dot-prefixed syntax nginx itself accepts for map keys.Describe the proposed solution
enable_hostnames(BooleanField) tosni_hostname_upstream_map,exposed as a checkbox on the map's edit form, rendered as
hostnames;in the generated
map {}block instreams.conf.map_proxy_protocol(BooleanField) tostream_server, exposed asa checkbox on the stream server form, rendered as
proxy_protocol on|off;right after
proxy_pass $hostmap...;instreams.conf(only applies to thesni_upstream_maprouting mode).sni_hostname_upstream_map_item.hostnamefromHostnameFieldto a
TextFieldwith aMaskcovering nginx's full map key syntax:exact hostnames,
*,*.example.com,www.example.*,.example.com,and case-sensitive/insensitive regular expressions (
~...,~*...), quoted(single or double) or unquoted. The mask explicitly excludes
;,{and}fromevery branch, since the value is written verbatim into the generated
.conffile.No controller or JS changes were required for the GUI options themselves; both new checkboxes are plain top-level fields already handled by the existing
addBase()/setBase()flow.While testing this feature I found and fixed an unrelated pre-existing bug (orphaned map/ACL items on edit, blocking deletion of referenced upstreams) — see #5654, tested together with these changes.
Related issue
Closes #5596