Introduced support for load balancing through upstream hosts and customizable Real IP header source#5413
Conversation
|
Docker Image for build 6 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! |
|
I might be missing something, but does this only add LB to HTTP and HTTPS connections? Would this be able to LB other ports / TCP and UDP streams i.e. Any LB should implement health checks to ensure that the upstream hosts are online and available. |
Code Review — Upstream Hosts + Real IP HeaderThanks for this substantial contribution. The overall structure is solid and the test coverage is appreciated. A few issues need addressing before this can merge, ranging from blockers to low-priority fixes. 🔴 Critical1. Nginx directive injection via custom
🔴 High2.
3.
4. Asset caching broken for upstream hosts
5.
🟡 Medium6. Startup wipes all configs before regeneration (outage risk)
7. Double nginx reload on upstream host update
8.
9. No format validation on
10. React state mutation during render in
11. Dual state divergence in
🟢 Low12. Slovak locale replaced with Czech
13. Garbled translations in
14. Migration:
15. Missing test coverage
SummaryIssues #1 (directive injection), #3 (ip_hash/weight nginx incompatibility), and #6 (startup outage risk) are blockers. Issue #2 (real_ip_header absent when IP range fetching is disabled) is a significant regression for a real user segment. The translation issues (#12, #13) are easy wins to address now. The underlying feature design is good and solves real problems — looking forward to seeing a revised version. |
Upstream Hosts, Real IP Header setting, and Cloudflare compatibility
Closes #5374
Closes #156
Heavily influenced by #5184
Summary
This PR introduces two major features: Upstream Hosts for load balancing across multiple backend servers, and a configurable Real IP Header setting that fixes Access List IP whitelisting when behind Cloudflare or other CDNs.
Features
Upstream Hosts
A new first-class entity for managing reusable nginx
upstreamgroups. Upstream hosts support three load balancing methods: round-robin, least connections, and IP hash, each with configurable server weights.upstream_host,upstream_host_server), internal logic, REST API (/api/nginx/upstream-hosts), access control rules, schema definitions, and nginx template (upstream_host.conf)upstream_hostandupstream_host_servertables, addsupstream_host_idforeign key toproxy_hostreact-selectdropdown matching the proxy host UXReal IP Header Setting
A new global setting under Settings > Real IP Header that controls which HTTP header nginx uses for
real_ip_header. This enables Access Lists to work behind Cloudflare.X-Real-IP(default),CF-Connecting-IP(Cloudflare),X-Forwarded-For, or a custom header namereal_ip_headerdirective is moved from the staticnginx.confinto the dynamically generatedip_ranges.conf. Changing the setting triggers config regeneration and nginx reloaddefault-siteandreal-ip-headervaluesStartup Config Regeneration
All nginx host configs are now deleted and regenerated from current templates on every startup. This ensures configs on disk always match the current template version after an upgrade, preventing stale configs from blocking nginx. For example, if a template change adds or removes a directive, old configs with the previous format would cause nginx to fail to start. Regenerating on startup eliminates this class of issues entirely.
Translations
All new keys are translated across all 22 supported locales (bg, cs, de, es, et, fr, ga, hu, id, it, ja, ko, nl, no, pl, pt, pt_br, ru, sk, tr, vi, zh) with proper native-language translations.
AI Disclosure
AI (Claude) was used as a development assistant during this work. All changes have been tested on a deployed instance, however I would greatly appreciate additional QA help from the community to cover edge cases across different configurations and environments.