feat: Dynamic upstream DNS resolution for proxy hosts#5487
Conversation
When enabled, nginx resolves the upstream hostname at request time using Docker's internal DNS resolver (127.0.0.11) instead of only at startup. This prevents nginx from failing when an upstream container is not yet running or restarts with a new IP.
|
CI is failing because the API schema is missing some examples |
Code ReviewThanks for the PR — the overall structure is solid and follows the pattern established by That said, there are a few issues that need addressing before this can merge. 🔴 Critical — Feature doesn't work for the default locationThe For nginx to resolve dynamically, Fix: Add the same 🔴 Critical — Unrelated change to an existing migration file
Please revert this change. Style cleanup belongs in a separate PR if needed at all. 🟠 High — Resolver is hardcoded to Docker's internal DNS with no user warning
A user on any non-Docker-bridge deployment who enables this toggle will get a non-functional resolver — nginx may fail to start, or silently fail to proxy. There is no UI warning, tooltip, or documentation callout anywhere in the PR. At minimum, add descriptive text to the UI toggle explaining this is Docker-specific. Ideally the resolver address would be a configurable field rather than hardcoded. 🟡 Minor — Template indentation in
|
|
Actually on the topic of
It might be ok to merge this PR with this limitation, but a new PR should probably be created that addresses configuring the DNS to use either through the Settings in app or a Environment variable. |
…proto Migration files must be treated as immutable once committed. Revert the unrelated style change (arrow functions) introduced in a previous commit.
Instead of hardcoding 127.0.0.11 (Docker bridge DNS only), the resolver
address is now determined at startup using the following priority:
1. NGINX_RESOLVER environment variable (explicit override)
2. First nameserver entry in /etc/resolv.conf (system DNS)
3. Fallback to 127.0.0.11 (Docker bridge default)
This makes the feature usable outside of Docker bridge networks
(host-network, bare-metal, Kubernetes, etc.) without any code change.
Also fix template indentation for the resolver directive to match the
2-space convention used by other directives in the server{} block.
Add a descriptive sub-line under the toggle explaining that the DNS resolver is auto-detected but can be overridden via NGINX_RESOLVER. Also add French translation for both the label and the description.
The field was missing from the Formik initialValues, causing the checkbox to fall back to native HTML behavior and send ["on"] instead of a boolean, which failed schema validation with 400 Bad Request.
|
Here's what was addressed in this update: 🔴 Migration file (revert):Tthe file ( 🔴 Default location /
|
|
Docker Image for build 7 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! |
Summary
Adds a "Dynamic Upstream Resolve" toggle to proxy hosts. When enabled,
nginx uses a
resolverdirective and a$upstream_hostvariable sothat the upstream hostname is resolved at request time via Docker's
internal DNS (127.0.0.11), rather than once at nginx startup.
This is useful when the upstream container may not be running when
nginx starts, or when its IP can change (e.g. after a restart).
Changes
dynamic_upstream_resolvetinyint column toproxy_hostboolFieldsresolver 127.0.0.11 valid=10sin theserver block and
set $upstream_hostin custom locations when enableddynamic_upstream_resolveto the locationrendering context (was missing, causing the variable to be ignored)
host.flags.dynamic-upstream-resolvekey to all localesNotes
This feature is Docker-specific. The resolver
127.0.0.11is Docker'sembedded DNS and is only available inside a Docker network bridge.