[GH-ISSUE #5316] [Feature]: Subscription LoadBalancer #3725

Closed
opened 2026-10-31 20:34:30 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @fmotalleb on GitHub (Jun 14, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5316

The recent addition of subscription support for outbounds is a significant improvement.
At the same time, x-ui provides a powerful balancer feature that can distribute traffic between multiple outbounds using strategies such as load balancing or lowest-latency selection.

Currently, these two features are disconnected. While subscriptions can dynamically create and update outbounds, balancers still require users to select individual outbounds manually.

For users who rely on subscriptions, maintaining balancers will become difficult and error-prone, since the outbounds may be renamed/removed/added.

Describe the solution you'd like

The most intuitive solution would be to allow a subscription to be selected as a balancer in routing rules.

Alternatives you've considered

Another useful alternative would be allowing balancers to select outbounds using patterns.
As balancers add outbounds with a tag prefix, maybe we could add, for example, sub1-* as a balancer member, and it would expand to all matching outbounds.
This scenario is more complex, as it may match against multiple subscriptions/outbounds, and notifying the balancer of changes based on matching prefixes may require a pub/sub scenario that may be harder to implement correctly.

Concrete use case

No response

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

Xray config generation

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @fmotalleb on GitHub (Jun 14, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5316 ### Is your feature request related to a problem? The recent addition of subscription support for outbounds is a significant improvement. At the same time, x-ui provides a powerful balancer feature that can distribute traffic between multiple outbounds using strategies such as load balancing or lowest-latency selection. Currently, these two features are disconnected. While subscriptions can dynamically create and update outbounds, balancers still require users to select individual outbounds manually. For users who rely on subscriptions, maintaining balancers will become difficult and error-prone, since the outbounds may be renamed/removed/added. ### Describe the solution you'd like The most intuitive solution would be to allow a subscription to be selected as a balancer in routing rules. ### Alternatives you've considered Another useful alternative would be allowing balancers to select outbounds using patterns. As balancers add outbounds with a tag prefix, maybe we could add, for example, `sub1-*` as a balancer member, and it would expand to all matching outbounds. This scenario is more complex, as it may match against multiple subscriptions/outbounds, and notifying the balancer of changes based on matching prefixes may require a pub/sub scenario that may be harder to implement correctly. ### Concrete use case _No response_ ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? Xray config generation ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [ ] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
bsakaguchi 2026-10-31 20:34:30 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 14, 2026):

The prefix/wildcard selector alternative you described already works today — no code changes required. The gap is UX: the panel does not surface this workflow, so it is easy to miss.

How it works now

Each outbound subscription has a configurable TagPrefix (set in the subscription form). When left blank it defaults to sub{id}- (e.g., sub1-, sub2-). All outbounds fetched from that subscription receive tags prefixed with that string and those tags are stable across refreshes (see internal/web/service/outbound_subscription.go, lines 503–540).

The balancer selector field is rendered as an Ant Design mode="tags" select (frontend/src/pages/xray/balancers/BalancerFormModal.tsx, line 164), which means you can type any arbitrary string — not only the suggested tags from the dropdown. Whatever you type is written verbatim into the Xray config balancers[].selector array.

Xray-core interprets each selector element as a prefix: any outbound whose tag starts with that string is included in the balancer pool. The codebase comment at outbound_subscription.go lines 524–527 describes this explicitly:

If you use a prefix/wildcard selector (e.g. "hk-*", "sg-.*"), then any new servers that the subscription later returns will automatically be eligible for that balancer on the next Xray reload — this is the recommended way to "subscribe to a pool".

Practical steps (no update needed)

  1. Open the subscription editor and note (or set) the TagPrefix. Example: set it to myprovider-.
  2. Open the balancer editor. In the Selector field, type myprovider- and press Enter to add it as a tag.
  3. Save and reload Xray. The balancer will include every current and future outbound from that subscription, as long as their prefix matches.

If you use the default prefix (e.g., sub1-) make sure no other outbounds share that prefix unintentionally.

What is still missing (the real feature gap)

The UX does not guide users to this pattern:

  • The subscription list does not prominently display the effective TagPrefix for each subscription.
  • The balancer selector dropdown only suggests existing concrete outbound tags; it does not offer the subscription prefix as an option.
  • There is no "Link to subscription" shortcut in the balancer form that would populate the selector with the correct prefix automatically.

A first-class UI improvement — adding subscription prefixes as suggested options in the balancer selector dropdown, or a dedicated "Source subscription" selector — would make this workflow discoverable and reduce manual configuration errors. The backend already supports it; only frontend changes in frontend/src/pages/xray/balancers/BalancerFormModal.tsx and the data passed down from frontend/src/pages/xray/XrayPage.tsx would be needed (the subscription TagPrefix values are already available via the settings API response).

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4701664683 --> @github-actions[bot] commented on GitHub (Jun 14, 2026): The **prefix/wildcard selector alternative you described already works today** — no code changes required. The gap is UX: the panel does not surface this workflow, so it is easy to miss. **How it works now** Each outbound subscription has a configurable `TagPrefix` (set in the subscription form). When left blank it defaults to `sub{id}-` (e.g., `sub1-`, `sub2-`). All outbounds fetched from that subscription receive tags prefixed with that string and those tags are stable across refreshes (see `internal/web/service/outbound_subscription.go`, lines 503–540). The balancer `selector` field is rendered as an Ant Design `mode="tags"` select (`frontend/src/pages/xray/balancers/BalancerFormModal.tsx`, line 164), which means you can type any arbitrary string — not only the suggested tags from the dropdown. Whatever you type is written verbatim into the Xray config `balancers[].selector` array. Xray-core interprets each selector element as a prefix: any outbound whose tag starts with that string is included in the balancer pool. The codebase comment at `outbound_subscription.go` lines 524–527 describes this explicitly: > If you use a *prefix/wildcard* selector (e.g. `"hk-*"`, `"sg-.*"`), then any *new* servers that the subscription later returns will automatically be eligible for that balancer on the next Xray reload — this is the recommended way to "subscribe to a pool". **Practical steps (no update needed)** 1. Open the subscription editor and note (or set) the `TagPrefix`. Example: set it to `myprovider-`. 2. Open the balancer editor. In the **Selector** field, type `myprovider-` and press Enter to add it as a tag. 3. Save and reload Xray. The balancer will include every current and future outbound from that subscription, as long as their prefix matches. If you use the default prefix (e.g., `sub1-`) make sure no other outbounds share that prefix unintentionally. **What is still missing (the real feature gap)** The UX does not guide users to this pattern: - The subscription list does not prominently display the effective `TagPrefix` for each subscription. - The balancer selector dropdown only suggests existing concrete outbound tags; it does not offer the subscription prefix as an option. - There is no "Link to subscription" shortcut in the balancer form that would populate the selector with the correct prefix automatically. A first-class UI improvement — adding subscription prefixes as suggested options in the balancer selector dropdown, or a dedicated "Source subscription" selector — would make this workflow discoverable and reduce manual configuration errors. The backend already supports it; only frontend changes in `frontend/src/pages/xray/balancers/BalancerFormModal.tsx` and the data passed down from `frontend/src/pages/xray/XrayPage.tsx` would be needed (the subscription `TagPrefix` values are already available via the settings API response). *This reply was generated automatically; a maintainer may follow up.*
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
MHSanaei/3x-ui#3725
No description provided.