Proxy Groups
A proxy group (proxy-groups) is a combination of a series of proxies (or proxy groups). Proxy groups can be referenced by the routing rules just like individual proxies 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 without any proxies will be treated as the
DIRECT
strategy. - The
filter
field is supported to filter nodes using regular expressions. - All proxies and remote proxy sets can be referenced by using
include-all: true
.
Proxy Groups
By default, the order of proxies in a strategy group is based on the configuration file. However, you can change it to sort by latency test results on the "Network Settings" page.
url-test
url-test
can perform connectivity tests on the included proxies at regular intervals and automatically select the server with the shortest latency. Unhealthy proxies will be skipped.
- name: auto
type: url-test
proxies:
- ss1
- ss2
- vmess
interval: 300
fallback
fallback
attempts to select servers from top to bottom according to the order specified by the user, ensuring that the servers are available. Unhealthy proxies will be skipped.
- name: fallback-auto
type: fallback
proxies:
- ss1
- ss2
- vmess
load-balance
load-balance
fully utilizes the bandwidth of multiple proxies. Unhealthy proxies will be skipped.
- name: load-balance
type: load-balance
strategy: # consistent-hashing / round-robin
proxies:
- ss1
- ss2
- vmess
It is generally recommended to set the strategy
to consistent-hashing
to avoid triggering the server's security policy by frequently changing IP addresses.
select
select
allows users to manually select proxies.
- name: select
type: select
proxies:
- ss1
- ss2
- vmess
- auto
relay
The forwarding chain of proxies, where traffic is forwarded through a series of proxies to reach the destination. Only TCP forwarding is supported. 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 Tests
By default, Stash performs latency tests on the proxies included in the strategy group every 600 seconds. If the strategy group includes another strategy group, the tests will be performed recursively.
The scheduled latency tests can be modified with the following configurations:
interval
: The interval in seconds at which the latency tests are performed. The default is 600 seconds. Set it to a negative value to disable the latency tests.lazy
: If set totrue
, and the strategy group has not been used for a period of time, Stash will skip the automatic latency tests to save resources.
proxy-groups:
- name: my-proxy-group
type: select
# ...
interval: 300 # Perform the test every 300s
lazy: true # Skip the latency tests 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
. - If 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 when in a Wi-Fi environment with SSID "office"
# Automatically switch to the ss2 strategy when in a Wi-Fi environment with SSID "home"
# Automatically switch to the ss3 strategy when using cellular data
# For other SSIDs, use DIRECT by default
office: ss1
home: ss2
cellular: ss3
default: DIRECT
Flexible Combination of Proxies
Stash supports various ways to combine multiple proxies into one strategy group.
- All proxies and remote proxy sets can be referenced by using
include-all: true
. - A strategy group without any proxies will be treated as the
DIRECT
strategy. - The
filter
field is supported to filter nodes using regular expressions.
proxy-groups:
- name: my-hongkong-group
type: select
include-all: true # Reference all proxies & proxy-providers
filter: 'HK|香港' # Filter proxies containing the keywords HK or 香港