feat: outbound groups

This commit is contained in:
fufsob committed 2026-09-29 13:01:31 +00:00
1 parent c42bcb2f4f
commit fa0015d829
35 files changed
+2444 -210

No files matched your search

+8
View File
@@ -180,6 +180,7 @@ services.proxy-suite = {
strategy = null;
};
enable = false;
groups = { };
ipv6 = config.networking.enableIPv6;
listener = {
address = "127.0.0.1";
@@ -191,6 +192,7 @@ services.proxy-suite = {
port = 1080;
};
outbounds = [ ];
priority = { };
routing = {
block = {
domains = [ ];
@@ -335,10 +337,16 @@ services.proxy-suite = {
asOutbound = null;
autostart = false;
configFile = null;
devices = { };
domainStrategy = if config.networking.enableIPv6 then "prefer_ipv6" else "prefer_ipv4";
enable = false;
endpoint = null;
generatorUrl = null;
group = {
failback = true;
strategy = "failover";
};
instances = null;
};
whitelistBypass = {
creators = { };
+112 -5
View File
@@ -36,6 +36,14 @@ Part of the [proxy-suite options reference](./index.md).
- [rules](#services-proxy-suite-proxy-dns-singbox-rules)
- [servers](#services-proxy-suite-proxy-dns-singbox-servers)
- [strategy](#services-proxy-suite-proxy-dns-strategy)
- [groups](#services-proxy-suite-proxy-groups)
- `<name>`
- [failback](#services-proxy-suite-proxy-groups-name-failback)
- [interval](#services-proxy-suite-proxy-groups-name-interval)
- [match](#services-proxy-suite-proxy-groups-name-match)
- [outbounds](#services-proxy-suite-proxy-groups-name-outbounds)
- [strategy](#services-proxy-suite-proxy-groups-name-strategy)
- [subscriptions](#services-proxy-suite-proxy-groups-name-subscriptions)
- [ipv6](#services-proxy-suite-proxy-ipv6)
- listener
- [address](#services-proxy-suite-proxy-listener-address)
@@ -59,6 +67,7 @@ Part of the [proxy-suite options reference](./index.md).
- [url](#services-proxy-suite-proxy-outbounds-url)
- [urlFile](#services-proxy-suite-proxy-outbounds-urlfile)
- [xrayJson](#services-proxy-suite-proxy-outbounds-xrayjson)
- [priority](#services-proxy-suite-proxy-priority)
- routing
- block
- [domains](#services-proxy-suite-proxy-routing-block-domains)
@@ -352,6 +361,91 @@ Which IP versions to resolve\. Use ` ipv4_only ` if the uplink has no IPv6\. sin
**Default:** `null`\
**Example:** `"ipv4_only"`
<a id="services-proxy-suite-proxy-groups"></a>
## services\.proxy-suite\.proxy\.groups
Outbound groups: one tag standing for several outbounds, which picks among them\. A group
works wherever an outbound tag does: routing rules, ` detour `, pins, other groups\. Its
members are no longer picked on their own at the top level, only through the group\.
sing-box and hybrid only\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`\
**Example:**
```nix
{
warp-pool.outbounds = [ "warp-1" "warp-2" ];
eu = {
subscriptions = [ "community-list" ];
match = [ "de-*" ];
strategy = "urltest";
};
}
```
<a id="services-proxy-suite-proxy-groups-name-failback"></a>
## services\.proxy-suite\.proxy\.groups\.\<name>\.failback
With “failover”: go back to an earlier member once it has worked three checks in a
row\. Off: stay on the member it moved to until that one fails\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-proxy-groups-name-interval"></a>
## services\.proxy-suite\.proxy\.groups\.\<name>\.interval
How often members are tested (Go duration)\. ` null `: ` proxy.urlTest.interval ` for
“urltest”, 30s for “failover”\. Health checks of their own, such as the AmneziaWG
watchdog’s, trigger a test at once\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"15s"`
<a id="services-proxy-suite-proxy-groups-name-match"></a>
## services\.proxy-suite\.proxy\.groups\.\<name>\.match
Glob patterns (` * `, ` ? `) over outbound tags; every match is a member\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "de-*" ]`
<a id="services-proxy-suite-proxy-groups-name-outbounds"></a>
## services\.proxy-suite\.proxy\.groups\.\<name>\.outbounds
Member tags, in order: the failover order\. Any outbound or group tag\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "warp-1" "warp-2" ]`
<a id="services-proxy-suite-proxy-groups-name-strategy"></a>
## services\.proxy-suite\.proxy\.groups\.\<name>\.strategy
How the group picks a member:
- “failover”: the first member that works, in order; moves on within seconds of a
failure\.
- “urltest”: the fastest; ` proxy.urlTest.tolerance ` keeps it from switching over
small differences\.
- “selector”: the first member, or the one picked by hand\.
**Type:** one of “failover”, “urltest”, “selector”\
**Default:** `"failover"`
<a id="services-proxy-suite-proxy-groups-name-subscriptions"></a>
## services\.proxy-suite\.proxy\.groups\.\<name>\.subscriptions
Subscriptions whose every entry is a member, as the subscription holds them at start\.
**Type:** list of string\
**Default:** `[ ]`\
**Example:** `[ "community-list" ]`
<a id="services-proxy-suite-proxy-ipv6"></a>
## services\.proxy-suite\.proxy\.ipv6
@@ -541,6 +635,17 @@ Raw XRay outbound JSON, instead of ` url ` (XRay backend)\. Its tag is replaced\
**Default:** `null`\
**Example:** `{ protocol = "vless"; settings = { address = "example.com"; }; }`
<a id="services-proxy-suite-proxy-priority"></a>
## services\.proxy-suite\.proxy\.priority
Order of outbounds and groups, lower first: which one “first” and “failover” take, and the
order of group members pulled in by ` subscriptions ` or ` match `\. Tags not listed come after,
in their usual order\. ` proxy-ctl proxy priority ` changes it at runtime\.
**Type:** attribute set of signed integer\
**Default:** `{ }`\
**Example:** `{ de-vps = 20; warp-pool = 10; }`
<a id="services-proxy-suite-proxy-routing-block-domains"></a>
## services\.proxy-suite\.proxy\.routing\.block\.domains
@@ -819,18 +924,20 @@ Rule sets from ` proxy.routing.ruleSets ` that this rule matches (sing-box and h
<a id="services-proxy-suite-proxy-selection"></a>
## services\.proxy-suite\.proxy\.selection
How to pick an outbound:
How to pick an outbound among the top-level ones: groups and outbounds in no group\.
- “first”: the pinned one, or else the first available\.
- “selector”: pick by hand\.
- “urltest”: the fastest, unless one is pinned\.
- “failover”: the first one that works, in ` priority ` order; moves on within seconds
of a failure and comes back once the earlier one works again\. sing-box and hybrid only\.
` proxy-ctl proxy pin ` works in every mode and survives restarts\. On sing-box, “selector”
and “urltest” switch without restarting the backend\.
` proxy-ctl proxy pin ` works in every mode and survives restarts\. On sing-box, “selector”,
“urltest” and “failover” switch without restarting the backend\.
**Type:** one of “first”, “selector”, “urltest”\
**Type:** one of “first”, “selector”, “urltest”, “failover”\
**Default:** `"first"`\
**Example:** `"urltest"`
**Example:** `"failover"`
<a id="services-proxy-suite-proxy-selectionexclude"></a>
## services\.proxy-suite\.proxy\.selectionExclude
+66
View File
@@ -12,9 +12,17 @@ Part of the [proxy-suite options reference](./index.md).
- [asOutbound](#services-proxy-suite-warp-asoutbound)
- [autostart](#services-proxy-suite-warp-autostart)
- [configFile](#services-proxy-suite-warp-configfile)
- [devices](#services-proxy-suite-warp-devices)
- `<name>`
- [configFile](#services-proxy-suite-warp-devices-name-configfile)
- [endpoint](#services-proxy-suite-warp-devices-name-endpoint)
- [domainStrategy](#services-proxy-suite-warp-domainstrategy)
- [endpoint](#services-proxy-suite-warp-endpoint)
- [generatorUrl](#services-proxy-suite-warp-generatorurl)
- group
- [failback](#services-proxy-suite-warp-group-failback)
- [strategy](#services-proxy-suite-warp-group-strategy)
- [instances](#services-proxy-suite-warp-instances)
<a id="services-proxy-suite-warp-enable"></a>
## services\.proxy-suite\.warp\.enable
@@ -68,6 +76,38 @@ through the local proxy if enabled\. WARP does not work until that succeeds\.
**Default:** `null`\
**Example:** `"/run/secrets/wgcf-profile.conf"`
<a id="services-proxy-suite-warp-devices"></a>
## services\.proxy-suite\.warp\.devices
Several WARP devices, each registered on its own and each an outbound with its tag\. With
two or more, the tag “warp” names a group of them (` warp.group `), so rules, pins and
chains naming “warp” fail over between them\. A device cannot be named “warp” then\.
With “interface”, a tag holds at most 11 characters (its interface is awg-\<tag>)\.
Empty: one device, “warp”, as ` configFile ` and ` endpoint ` above say\.
**Type:** attribute set of (submodule)\
**Default:** `{ }`\
**Example:** `{ warp-a = { }; warp-b.endpoint = "162.159.193.10:500"; } `
<a id="services-proxy-suite-warp-devices-name-configfile"></a>
## services\.proxy-suite\.warp\.devices\.\<name>\.configFile
This device’s WireGuard profile, as ` warp.configFile `\. ` null `: registered with wgcf\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"/run/secrets/warp-b.conf"`
<a id="services-proxy-suite-warp-devices-name-endpoint"></a>
## services\.proxy-suite\.warp\.devices\.\<name>\.endpoint
This device’s endpoint, as ` warp.endpoint ` (which it defaults to)\.
**Type:** null or string matching the pattern (\\\[\[0-9A-Fa-f:\.]+]|\[^]:\[]+):\[0-9]+\
**Default:** `null`\
**Example:** `"162.159.192.1:500"`
<a id="services-proxy-suite-warp-domainstrategy"></a>
## services\.proxy-suite\.warp\.domainStrategy
@@ -101,3 +141,29 @@ Its operator sees your private key\.
**Type:** null or string\
**Default:** `null`\
**Example:** `"https://valokda-amnezia.vercel.app/api/warp?mode=awg2"`
<a id="services-proxy-suite-warp-group-failback"></a>
## services\.proxy-suite\.warp\.group\.failback
With “failover”: go back to an earlier device once it works again\.
**Type:** boolean\
**Default:** `true`
<a id="services-proxy-suite-warp-group-strategy"></a>
## services\.proxy-suite\.warp\.group\.strategy
How the “warp” group of several devices picks one; see ` proxy.groups `\.
**Type:** one of “failover”, “urltest”, “selector”\
**Default:** `"failover"`
<a id="services-proxy-suite-warp-instances"></a>
## services\.proxy-suite\.warp\.instances
Shorthand for ` devices `: this many WARP devices, warp-1 to warp-N, each registered with
wgcf\. warp-1 keeps the registration a single “warp” device made\. Not with ` devices `\.
**Type:** null or (positive integer, meaning >0)\
**Default:** `null`\
**Example:** `2`
+14
View File
@@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "de-vps"; urlFile = "/run/secrets/de-vps-url"; }
{ tag = "nl-vps"; urlFile = "/run/secrets/nl-vps-url"; }
];
groups.eu.outbounds = [ "de-vps" "nl-vps" ]; # de-vps first, nl-vps when it fails
};
};
}
+12
View File
@@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.proxy = {
enable = true;
subscriptions = [ { tag = "provider"; urlFile = "/run/secrets/provider-sub"; } ];
groups.fast = {
subscriptions = [ "provider" ]; # every entry the subscription holds
match = [ "de-*" ]; # and every outbound whose tag matches
strategy = "urltest";
};
};
}
+8
View File
@@ -0,0 +1,8 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.proxy = {
enable = true;
selection = "failover";
priority = { eu = 10; warp = 20; };
};
}
+13
View File
@@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite = {
enable = true;
amneziaWg.enable = true;
proxy.enable = true;
warp = {
enable = true;
asOutbound = "interface";
instances = 2; # warp-1 (keeps an existing registration) and warp-2
};
};
}
+12
View File
@@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
{
services.proxy-suite.warp = {
enable = true;
asOutbound = "interface";
devices = {
warp-a = { };
warp-b.endpoint = "162.159.193.10:500";
};
group.strategy = "failover";
};
}
+133
View File
@@ -0,0 +1,133 @@
# Group outbounds and fail over
A group is one tag standing for several outbounds. Whatever names the group (a routing rule,
a chain, a pin, the top-level pick) uses whichever member the group picks. The usual reason
is failover: when one exit stops carrying traffic, move to the next within seconds instead of
waiting for someone to notice.
## A failover group
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [
{ tag = "de-vps"; urlFile = "/run/secrets/de-vps-url"; }
{ tag = "nl-vps"; urlFile = "/run/secrets/nl-vps-url"; }
];
groups.eu.outbounds = [ "de-vps" "nl-vps" ]; # de-vps first, nl-vps when it fails
};
};
```
The members leave the top level: the top level now picks between `eu` and whatever is in no
group. Members can be any outbound, including subscription entries, WARP, Tor and AmneziaWG,
and other groups.
Each group has a `strategy`:
| Strategy | Picks |
|---|---|
| `failover` (default) | The first member that works, in order. With `failback` (on by default) it goes back to an earlier member once that has worked three checks in a row. |
| `urltest` | The fastest member, switching only when another is faster by `proxy.urlTest.tolerance`. |
| `selector` | The first member, or the one you pick. |
Failover is driven by `proxy-suite-outbound-groups`, which tests the members every `interval`
(30 s by default) and switches through sing-box's Clash API. A member is down after two
failed tests in a row. Watchdogs that already watch a tunnel (the AmneziaWG watchdog, the
sing-box WARP tunnel) tell it at the first sign of trouble, so their outbounds are dropped
within seconds. Connections still open on the dropped member are cut, so clients reconnect
through the next one.
Groups need the sing-box or hybrid backend. The TUN instances of sing-box have no Clash API,
so there a failover group works as `urltest`.
## Members from subscriptions and patterns
```nix
services.proxy-suite.proxy = {
enable = true;
subscriptions = [ { tag = "provider"; urlFile = "/run/secrets/provider-sub"; } ];
groups.fast = {
subscriptions = [ "provider" ]; # every entry the subscription holds
match = [ "de-*" ]; # and every outbound whose tag matches
strategy = "urltest";
};
};
```
Listed `outbounds` come first, in their order; members pulled in by `subscriptions` or `match`
follow, ordered by `proxy.priority`.
## Failover at the top level, and priority
`proxy.selection = "failover"` treats the top level like a failover group. Its order comes
from `proxy.priority`, lower first; anything not listed follows in its usual order:
```nix
services.proxy-suite.proxy = {
enable = true;
selection = "failover";
priority = { eu = 10; warp = 20; };
};
```
## Several WARP devices
One WARP device is one key and one session. With several, `warp` becomes a failover group of
them, so rules and pins that name `warp` keep working and fail over:
```nix
services.proxy-suite = {
enable = true;
amneziaWg.enable = true;
proxy.enable = true;
warp = {
enable = true;
asOutbound = "interface";
instances = 2; # warp-1 (keeps an existing registration) and warp-2
};
};
```
Name them yourself, each with its own endpoint, through `warp.devices`:
```nix
services.proxy-suite.warp = {
enable = true;
asOutbound = "interface";
devices = {
warp-a = { };
warp-b.endpoint = "162.159.193.10:500";
};
group.strategy = "failover";
};
```
Devices whose outages come at the same time (the path to Cloudflare, say) do not help each
other; a different endpoint for each, or a member that is not WARP, does.
## At runtime
```sh
proxy-ctl proxy outbounds # the tree: groups, members, what each uses
proxy-ctl proxy groups add eu de-vps nl-vps # a failover group
proxy-ctl proxy groups add fast --sub provider --strategy urltest
proxy-ctl proxy groups members eu add pl-vps
proxy-ctl proxy pin nl-vps --in eu # hold eu on nl-vps
proxy-ctl proxy unpin --in eu
proxy-ctl proxy priority eu 5 # or: eu up, eu down, eu --clear
proxy-ctl warp restart warp-2
```
Groups added at runtime can be changed and removed there; declared ones change in Nix. In
the TUI and the GUI, the Outbounds tab shows the same tree: `space` folds a group, `p` on a
member pins it inside its group, `g` adds a group, and `+` and `-` move a top-level entry.
## See also
- [`proxy.groups`](../options/proxy.md#services-proxy-suite-proxy-groups)
- [`proxy.priority`](../options/proxy.md#services-proxy-suite-proxy-priority)
- [`warp.devices`](../options/warp.md#services-proxy-suite-warp-devices)
- [Chain proxies and add exits](./chains.md)
+1
View File
@@ -17,6 +17,7 @@ examples follow below.
| [Control it day to day](./control.md) | Switching things without editing Nix or typing sudo |
| [Use an AmneziaWG config](./amneziawg.md) | You have an AmneziaWG `.conf` or an Amnezia `vpn://` export |
| [Chain proxies and add exits](./chains.md) | WARP, Tor, SSH, or reaching a server through another one |
| [Group outbounds and fail over](./groups.md) | Several exits for one job, moving off one that stops working |
| [Other Linux and Android](./other-hosts.md) | You are not on NixOS |
| [Get past mobile whitelists](./whitelist-bypass.md) | Mobile internet lets only whitelisted services through |