fix(stream): bracket IPv6 forward host for valid nginx upstream#5741
Open
addielaruee wants to merge 1 commit into
Open
fix(stream): bracket IPv6 forward host for valid nginx upstream#5741addielaruee wants to merge 1 commit into
addielaruee wants to merge 1 commit into
Conversation
A Stream Host with an IPv6 address as the Forward Host was accepted and
saved but never activated. The generated stream config rendered
`proxy_pass {{ forwarding_host }}:{{ forwarding_port }}` as e.g.
`fe80::528:3c87:e7bb:ab08:25`, which nginx rejects with
"invalid port in upstream" because an IPv6 literal must be wrapped in
square brackets before the port is appended (`[fe80::...]:25`).
Normalize the stream forward host in generateConfig (alongside the existing
per-host-type data massaging) using net.isIPv6(), so IPv6 hosts render as
`[address]:port` while IPv4 addresses and hostnames are emitted unchanged.
The mutation is applied to the deep-copied render object, so persisted and
audit data are unaffected.
Fixes NginxProxyManager#5740
|
Docker Image for build 1 is available on DockerHub: Note Ensure you backup your NPM instance before testing this image! Especially if there are database changes. Warning Changes and additions to DNS Providers require verification by at least 2 members of the community! |
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.
Why
Fixes #5740.
When a Stream Host uses an IPv6 address as its Forward Host, NPM accepts and stores it, but the generated nginx stream config is invalid, so the stream saves yet never activates.
backend/templates/stream.confrenders the upstream as:For
forwarding_host = fe80::528:3c87:e7bb:ab08,forwarding_port = 25this produces:which nginx rejects, because an IPv6 literal must be wrapped in square brackets before the port:
The stream row is saved (
nginx_online: false), but the config never loads.Fix
Normalize the stream forward host in
internalNginx.generateConfig, in the same "manipulate the data before the template" block that already special-casesredirection_host. Using Node'snet.isIPv6()(authoritative, no regex/heuristics), an IPv6 forward host is wrapped in brackets so it rendersproxy_pass [address]:port;; IPv4 addresses and hostnames are left untouched.generateConfigoperates on a deep copy of the row (JSON.parse(JSON.stringify(host_row))), so persisted and audit-log data are unaffected — this only shapes the value handed to the template.Scope is intentionally limited to Stream Hosts (the reported bug). Proxy Hosts use a different field/template path and are out of scope here.
Verification
Rendered the real
backend/templates/stream.confwith LiquidJS 10.27.0 (the version inbackend/package.json) after applying the same normalization:proxy_passfe80::528:3c87:e7bb:ab08(bug report)proxy_pass [fe80::528:3c87:e7bb:ab08]:25;✅::1proxy_pass [::1]:25;✅192.168.1.10proxy_pass 192.168.1.10:25;(unchanged) ✅backend.internalproxy_pass backend.internal:25;(unchanged) ✅biome lintpasses on the changed file.Type of Change
AI Usage