[PR #3841] feat(streams): Simple Load Balancing of Streams #3769

Open
opened 2026-02-26 08:31:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/NginxProxyManager/nginx-proxy-manager/pull/3841
Author: @Teagan42
Created: 6/30/2024
Status: 🔄 Open

Base: developHead: feat/stream-load-balancing


📝 Commits (8)

  • f368985 feat(streams): Add multiple upstreams for basic load balancing
  • ffeb190 feat(streams): Regex for host or host with port
  • f65f15a feat(streams): Remove schema for host,ipv4,ipv6 with port
  • 85e7eba feat(streams): Add migration for chaning `forwarding_host' to 'forwarding_hosts'
  • 499933e chore(streams): Lint fixes
  • 32fb98f Fix template
  • d007b5c feat(streams): Add least connection and max_fails if hosts > 1
  • fb5e40a Update frontend/js/i18n/messages.json

📊 Changes

10 files changed (+148 additions, -28 deletions)

View changed files

backend/migrations/20240629165112_stream_load_balance.js (+42 -0)
📝 backend/models/stream.js (+17 -7)
📝 backend/schema/endpoints/streams.json (+25 -9)
📝 backend/templates/stream.conf (+27 -4)
📝 frontend/js/app/nginx/stream/form.ejs (+3 -3)
📝 frontend/js/app/nginx/stream/form.js (+25 -1)
📝 frontend/js/app/nginx/stream/list/item.ejs (+5 -1)
📝 frontend/js/app/nginx/stream/list/main.ejs (+1 -0)
📝 frontend/js/i18n/messages.json (+2 -2)
📝 frontend/js/models/stream.js (+1 -1)

📄 Description

Credit to https://github.com/eedev - Their PR was marked stale: https://github.com/NginxProxyManager/nginx-proxy-manager/pull/1999

Motivation

I wanted to use Nginx Proxy Manager to do some simple load balancing for a EMQX cluster, seems I am not alone:

Description

I followed #1999 - unfortunately, that PR is very stale, so it was easier to branch off of upstream develop and re-implement the changes and perform the eslint fixes.

If your stream contains multiple upstreams - it will use the least connection strategy and max_fails=3

Alternative Approaches

A more robust solution would allow for specifying the upstream port for each of the forwarding hosts (upstreams). I did toy around with this but decided it was more work than I wanted to do right now and was worried it may break other user configurations.

Future Enhancements

  • Advanced Options: Load Balancing Strategies, Allow Different Ports per Upstream, Other Proxy Settings
  • SSL

Screenshots

image


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/NginxProxyManager/nginx-proxy-manager/pull/3841 **Author:** [@Teagan42](https://github.com/Teagan42) **Created:** 6/30/2024 **Status:** 🔄 Open **Base:** `develop` ← **Head:** `feat/stream-load-balancing` --- ### 📝 Commits (8) - [`f368985`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/f368985a60663af9a93c0b7955f2231352e754ad) feat(streams): Add multiple upstreams for basic load balancing - [`ffeb190`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/ffeb190b3fc2221cb4f3acd2f9508676cf528894) feat(streams): Regex for host or host with port - [`f65f15a`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/f65f15af0172c94a03507920134ede18610c9613) feat(streams): Remove schema for host,ipv4,ipv6 with port - [`85e7eba`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/85e7ebac0c45ce3a2da4c8f8e4bc2747dfa32b26) feat(streams): Add migration for chaning `forwarding_host' to 'forwarding_hosts' - [`499933e`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/499933e4240d267fbd257ecffde878bf4c9429dd) chore(streams): Lint fixes - [`32fb98f`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/32fb98fb7ccae32b18a00b48e631029676f3146b) Fix template - [`d007b5c`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/d007b5c8a4c7287753cc640e2ccfd4f1d68ad1fd) feat(streams): Add least connection and max_fails if hosts > 1 - [`fb5e40a`](https://github.com/NginxProxyManager/nginx-proxy-manager/commit/fb5e40aa29d1b993a84ff9d27c3209781638da60) Update frontend/js/i18n/messages.json ### 📊 Changes **10 files changed** (+148 additions, -28 deletions) <details> <summary>View changed files</summary> ➕ `backend/migrations/20240629165112_stream_load_balance.js` (+42 -0) 📝 `backend/models/stream.js` (+17 -7) 📝 `backend/schema/endpoints/streams.json` (+25 -9) 📝 `backend/templates/stream.conf` (+27 -4) 📝 `frontend/js/app/nginx/stream/form.ejs` (+3 -3) 📝 `frontend/js/app/nginx/stream/form.js` (+25 -1) 📝 `frontend/js/app/nginx/stream/list/item.ejs` (+5 -1) 📝 `frontend/js/app/nginx/stream/list/main.ejs` (+1 -0) 📝 `frontend/js/i18n/messages.json` (+2 -2) 📝 `frontend/js/models/stream.js` (+1 -1) </details> ### 📄 Description Credit to https://github.com/eedev - Their PR was marked stale: https://github.com/NginxProxyManager/nginx-proxy-manager/pull/1999 # Motivation I wanted to use Nginx Proxy Manager to do some simple load balancing for a EMQX cluster, seems I am not alone: * #156 * #1963 * #2840 # Description I followed #1999 - unfortunately, that PR is very stale, so it was easier to branch off of upstream develop and re-implement the changes and perform the eslint fixes. If your stream contains multiple upstreams - it will use the least connection strategy and max_fails=3 # Alternative Approaches A more robust solution would allow for specifying the upstream port for each of the forwarding hosts (upstreams). I did toy around with this but decided it was more work than I wanted to do right now and was worried it may break other user configurations. # Future Enhancements * Advanced Options: Load Balancing Strategies, Allow Different Ports per Upstream, Other Proxy Settings * SSL # Screenshots ![image](https://github.com/NginxProxyManager/nginx-proxy-manager/assets/2989925/382d1bb9-8455-43f3-bc76-d5b18e9c3d29) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#3769
No description provided.