Policies

A policy tells Surge how to handle a request once a rule has matched it: connect directly, reject it, or forward it to a proxy server. Every rule ends with a policy name, and the FINAL rule picks the policy for all unmatched requests.

There are three kinds of policies:

  • Built-in policies: predefined policies such as DIRECT and REJECT. See Built-in Policies and the REJECT family.
  • Proxy policies: forward the request to a proxy server. Declared in the [Proxy] section.
  • Policy groups: select one policy from a set of policies, manually or automatically. See Policy Groups.

The [Proxy] Section

Each line in the [Proxy] section declares one proxy policy:

Name = <type>, <arguments...>, key1=value1, key2=value2

For all server-based proxy types, the first two arguments are the server hostname and port. The remaining parameters are written as key=value pairs. Quote a value if it contains commas.

[Proxy]
ProxyHTTPS = https, 1.2.3.4, 443, username, password
ProxySS = ss, 1.2.3.4, 8388, encrypt-method=chacha20-ietf-poly1305, password=pwd
ProxySnell = snell, 1.2.3.4, 8000, psk=pwd, version=5

Referencing Policies

A policy name can be used anywhere a policy is accepted:

  • As the target of a rule: DOMAIN-SUFFIX,example.com,ProxySS
  • As a member of a policy group: Group = select, ProxySS, ProxySnell, DIRECT
  • As the value of the underlying-proxy parameter to build a proxy chain.

Supported Proxy Protocols

Type keyword Protocol Notes
http / https HTTP / HTTPS HTTPS = HTTP proxy over TLS
h2-connect HTTP/2 CONNECT Mac 6.6.0+
socks5 / socks5-tls SOCKS5 / SOCKS5-TLS
ss Shadowsocks
snell Snell Versions 1–6
vmess VMess
trojan Trojan
tuic / tuic-v5 TUIC QUIC-based
hysteria2 Hysteria 2 QUIC-based iOS 5.8.0+ Mac 5.4.0+
masque MASQUE QUIC-based iOS 5.22.0+ Mac 6.9.0+
anytls AnyTLS iOS 5.17.0+ Mac 6.4.3+
vless VLESS iOS 6.0.0+ Mac 6.12.0+
trust-tunnel Trust Tunnel Mac 6.4.4+
ssh SSH
wireguard WireGuard L3 VPN as proxy
tailscale Tailscale iOS 5.20.0+ Mac 6.7.0+
external External Proxy Program Mac Only

The built-in type keywords direct, reject, reject-drop, reject-no-drop, and reject-tinygif may also appear in the [Proxy] section to define aliases of the built-in policies. See Built-in Policies.

The proxy editor can fill in a proxy from a share link: tap Import from Share Link under the protocol on iOS, or click Import… next to Share Link on Mac. A proxy line copied from a Surge profile (Name = type, ...) is accepted too. The link's name becomes the proxy name if the name field is empty, and settings a link cannot carry, such as the proxy chain and egress options, keep their current values.

Most of these link formats have no formal specification, so Surge accepts the forms in common use, including the variants written by v2rayN, Shadowrocket, sing-box, mihomo and Hiddify:

Link Imported as Notes
http://, https:// HTTP / HTTPS user:password@host:port; the port is required, and a link with a path is treated as a web address
socks://, socks5://, socks5h:// SOCKS5 Plain or base64 credentials
socks5+tls:// SOCKS5-TLS
ss:// Shadowsocks SIP002 (base64 or plain user info) and the legacy all-base64 form; obfs-local / simple-obfs and shadow-tls plugins, and Shadowrocket's shadow-tls parameter
vmess:// VMess v2rayN base64 JSON, Shadowrocket and Xray URI forms; TCP, WebSocket or HTTPUpgrade
vless:// VLESS See VLESS
trojan://, trojan-go:// Trojan TCP, WebSocket or HTTPUpgrade
hysteria2://, hy2:// Hysteria 2 Port lists such as host:443,5000-6000 and mport become port-hopping; obfs=salamander / gecko
tuic:// TUIC uuid:password for v5, a token alone for v4
anytls:// AnyTLS
snell:// Snell Version 4 unless version is given
tt:// Trust Tunnel TrustTunnel deep links, and the user:password@host:port form
wireguard://, wg:// WireGuard The private key is the user info; publickey, address, reserved, mtu, dns, presharedkey, keepalive
ssh:// SSH Password authentication; hk sets the server fingerprints. Links that embed a private key are not imported: add the key to the keystore and choose it in the editor.

TLS parameters common to these links map to the TLS Parameters: sni / peer to sni, allowInsecure / insecure to skip-cert-verify, alpn, pinSHA256 / pcs to server-cert-fingerprint-sha256, and vcn to server-cert-verify-name. The uTLS fingerprint (fp) is not used.

A link is never imported partially. Links that use something Surge cannot express are rejected with an error that names it. This includes:

  • transports other than TCP and WebSocket (gRPC is supported for VLESS only);
  • REALITY outside VLESS, and ECH;
  • v2ray-plugin and other Shadowsocks plugins;
  • AmneziaWG;
  • Hysteria v1, ShadowsocksR, NaiveProxy, Juicity and mieru.

Shared Parameters

Besides the protocol-specific parameters documented on each protocol page, several parameter groups are shared across policy types:

  • Common Policy Parameters: egress control (interface, ip-version, tfo, ...), testing (test-url, ...), and proxy chaining (underlying-proxy).
  • TLS Parameters: parameters shared by TLS- and QUIC-based protocols, plus Shadow TLS obfuscation.
  • UDP Relay: UDP protocol support matrix and related parameters.

results matching ""

    No results matching ""