feat: fix upstream host resolution edge case and support PEM paste in custom certificates#5348
feat: fix upstream host resolution edge case and support PEM paste in custom certificates#5348Eric-Terminal wants to merge 3 commits into
Conversation
…mpatibility Files changed: backend/internal/nginx.js. Purpose: provide an optional, NPM-side compatibility path for variable-based proxy_pass upstream resolution without changing existing Nginx templates or default behavior. Implementation: add environment flag NPM_PRE_RESOLVE_UPSTREAM_HOSTS (disabled by default); pre-resolve eligible upstream hostnames via dns.lookup() while generating proxy host and custom location configs; fall back to original hostname when resolution fails. Result: when enabled, setups using docker-compose extra_hosts (for example host.docker.internal) can avoid resolver host-not-found failures; when disabled, behavior remains backward compatible.
Add an Advanced Configuration section describing when to enable NPM_PRE_RESOLVE_UPSTREAM_HOSTS, example compose env usage, fallback behavior on resolution failure, and operational notes about generation-time resolution.
Add optional textarea inputs for certificate, certificate key, and intermediate certificate in CustomCertificateModal. At submit time, pasted PEM values are converted to File objects and uploaded via existing multipart API, so backend routes remain unchanged. Keep file upload path intact and require certificate + certificate key from either file input or pasted text before validation/upload.
|
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! |
Code ReviewBackend:
|
| Area | Concern | Severity |
|---|---|---|
| Backend | Single-IP resolution breaks load-balanced upstreams | Medium |
| Backend | Config staleness warning needs strengthening in docs | Medium |
| Backend | Async pattern inconsistency in generateConfig |
Low |
| Backend | No unit tests for new utility functions | Low |
| Frontend | No "OR" separator; silent file-over-text override | High |
| Frontend | Textareas missing <label> — accessibility issue |
Medium |
| Frontend | Noisy indentation-only diff changes | Low |
The core approach is sound — opt-in flag with safe fallback for the backend, reusing the existing API contract for the frontend. The two main items to address before merge: UX clarity around file vs. paste priority in the modal, and a docs/behaviour note about single-IP resolution affecting load-balanced upstreams.
This PR addresses two issues:
host.docker.internalcannot be resolved whenextra_hostsis used (variableproxy_pass+ resolver path) #53441) Optional upstream pre-resolution for
forward_host(issue #5344)Problem:
Nginx variable-based upstream resolution may fail for hostnames that are only resolvable through container/system resolver paths (for example
extra_hostsmappings likehost.docker.internal).What changed:
NPM_PRE_RESOLVE_UPSTREAM_HOSTS(default: disabled)dns.lookup)forward_hostand custom locationforward_hostBehavior:
2) Allow direct PEM paste in Custom Certificate modal (issue #5347)
Problem:
Custom certificate flow previously required local file selection, which is inconvenient in remote/mobile/thin-client workflows.
What changed:
Fileobjects client-side)validateanduploadmultipart APIs are reused without contract changesBehavior:
Docs
NPM_PRE_RESOLVE_UPSTREAM_HOSTS