Proxy Groups
A proxy group (or strategy group) is a combination of multiple proxies. Proxy groups can be referenced by routing rules like a single proxy, and can specify special strategies to improve availability.
- Routing rules can directly reference proxies or proxy groups, but cannot reference remote proxy sets.
- A strategy group can contain multiple proxies or multiple remote proxy sets.
- A strategy group can contain another strategy group.
- A strategy group that does not contain any proxies will be treated as the
DIRECT
strategy. - Supports the
filter
field to filter nodes with regular expressions. - All proxies and remote proxy sets can be referenced by using
include-all: true
.
Group Strategies
The default sorting method for proxies in a strategy group is the order in the configuration file, but it can be changed to sort by latency test results on the "Network" page.
url-test
url-test
can periodically perform connectivity checks on the included proxies, automatically selecting the server with the shortest delay, and skipping unhealthy proxies.
- name: auto
type: url-test
proxies:
- ss1
- ss2
- vmess
interval: 300
fallback
fallback
can automatically select servers from top to bottom according to the order in which the user writes them, while ensuring that the servers are available, and skipping unhealthy proxies.
- name: fallback-auto
type: fallback
proxies:
- ss1
- ss2
- vmess
load-balance
load-balance
can make full use of the bandwidth of multiple proxies, and skip unhealthy proxies.
- name: load-balance
type: load-balance
strategy: # consistent-hashing / round-robin
proxies:
- ss1
- ss2
- vmess
It is generally recommended to set strategy
to consistent-hashing
to avoid frequent IP changes triggering server-side security policies.
select
select
is used to allow users to manually select.
- name: select
type: select
proxies:
- ss1
- ss2
- vmess
- auto
relay
The proxy forwarding chain, traffic will be forwarded through a series of proxies to reach the destination, only supports forwarding TCP. The relay
strategy group is not affected by the results of internal proxy latency tests and requires a separate test URL to be specified.
- name: relay
type: relay
benchmark-url: http://www.apple.com # It is recommended to use only HTTP protocol
benchmark-timeout: 5 # Latency test timeout, in seconds
# Traffic: stash <-> http <-> vmess <-> ss1 <-> ss2 <-> Internet
proxies:
- http
- vmess
- ss1
- ss2
Additional Features
Scheduled Latency Test
By default, Stash will perform a latency test on the proxies contained in the strategy group every 600 seconds. If the strategy group contains another strategy group, the test will be performed recursively.
The scheduled latency test supports modifying the following configurations:
interval
: in seconds, perform a latency test at a certain interval, the default is 600 seconds, and setting it to a negative number will not perform a latency test.lazy
: lazy mode, if set totrue
, and the strategy group has not been used for a period of time, Stash will skip the automatic latency test.
proxy-groups:
- name: my-proxy-group
type: select
# ...
interval: 300 # Check every 300s
lazy: true # Do not perform latency test when the strategy group is not used
Automatic Strategy Switching Based on Network Status
The select
type strategy group can automatically switch strategies based on the device's SSID/cellular data.
default
and cellular
are two optional reserved strategies:
- When in a Wi-Fi environment and no SSID matches, it will automatically switch to the proxy corresponding to
default
. - When using cellular data, it will automatically switch to the proxy corresponding to
cellular
. - When there is no
default
orcellular
, no action will be triggered.
- name: ssid-group
type: select # The type must be select to be compatible with the original Clash configuration
proxies:
- ss1
- ss2
- ss3
- DIRECT
ssid-policy:
# Automatically switch to the ss1 strategy in the Wi-Fi environment with SSID office
# Automatically switch to the ss2 strategy in the Wi-Fi environment with SSID home
# Automatically switch to the ss3 strategy in cellular data
# Other SSIDs are set to DIRECT by default
office: ss1
home: ss2
cellular: ss3
default: DIRECT
Flexible Combination of Proxies
Stash supports various ways to combine multiple proxies into a strategy group.
- All proxies and remote proxy sets can be referenced by using
include-all: true
. - A strategy group that does not contain any proxies will be treated as the
DIRECT
strategy. - Supports the
filter
field to filter nodes with regular expressions.
proxy-groups:
- name: my-hongkong-group
type: select
include-all: true # Reference all proxies & proxy-providers
filter: 'HK|Hong Kong' # Filter proxies containing the keywords HK or Hong Kong