Skip to content

Subscription Clash Template

Alireza Ahmadi edited this page Sep 12, 2026 · 1 revision

Subscription Clash Template

Settings → Subscription → Clash

This template controls what …/sub/<client name>?format=clash returns — a Clash.Meta (Mihomo) YAML configuration.


How it works

Unlike the JSON template, the Clash template is an ordinary Clash configuration. The panel parses it as YAML, converts the client's nodes into Clash proxies, and merges them in:

  1. Generated proxies are appended to your proxies list (yours are kept).
  2. Proxy groups are merged (see below).
  3. Everything else in your template — rules, dns, tun, mode, log-level — is passed through untouched.

Leave the template empty and the panel uses a built-in default: mixed port 7890, TUN enabled, fake-ip DNS, and two rules (GEOIP,Private,DIRECT then MATCH,Proxy).


Proxy groups

By default the panel adds two groups and fills both with every node:

Group Type Contents
Proxy select Auto, then every node
Auto url-test Every node, tested every 300s with a 50ms tolerance

Your own groups are merged with these by name:

  • A group name that does not exist yet is added as you wrote it.
  • A group with the same name as a default one is merged into it: your proxies are appended to the generated list, and any other key you set (type, url, interval, icon…) wins over the default.
  • If you define your own Auto, the panel does not add a second one.

Two settings change this:

Setting Effect
subClashNoDefGrp Do not add Proxy and Auto at all. Only your groups survive — you are then responsible for putting nodes in them, usually with filter
subClashSprtAll Treat the literal proxy name all as "every node" and expand it in place

Filling your own groups

A group with no proxies gets nothing unless you say where its nodes come from. Two ways:

filter — a regular expression matched against node tags. Matching nodes are appended to the group. This works regardless of subClashSprtAll:

proxy-groups:
  - name: Germany
    type: url-test
    filter: "(?i)de|germany|frankfurt"
    url: http://www.gstatic.com/generate_204
    interval: 300
  - name: Netherlands
    type: url-test
    filter: "(?i)nl|amsterdam"
    url: http://www.gstatic.com/generate_204
    interval: 300

An invalid regular expression is logged and the group simply gets no nodes from it.

all — with subClashSprtAll enabled, the name all inside proxies expands to every node, in place, so you can mix it with fixed entries:

proxy-groups:
  - name: Proxy
    type: select
    proxies:
      - Auto
      - DIRECT
      - all

What the generated proxies look like

The panel converts each node from its sing-box form into Clash's. Supported types include vless, vmess, trojan, tuic, hysteria, hysteria2, shadowsocks, socks (emitted as socks5) and http. Selector, urltest and direct outbounds are not emitted as proxies — those are groups in Clash, which is what the proxy-group section is for.

A node's name is its tag, so the tags you see in the panel are the names you match with filter and reference from rules.

subClashUdp marks every generated proxy as UDP-capable. It is off by default because a node whose server does not actually forward UDP will silently blackhole it.


Examples

A working starting point

mixed-port: 7890
allow-lan: false
mode: rule
log-level: info
external-controller: 127.0.0.1:9090

dns:
  enable: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  nameserver:
    - https://1.1.1.1/dns-query
  fallback:
    - tcp://9.9.9.9:53

rules:
  - GEOIP,Private,DIRECT
  - GEOSITE,category-ads-all,REJECT
  - GEOSITE,ir,DIRECT
  - GEOIP,IR,DIRECT
  - MATCH,Proxy

The Proxy group referenced by the last rule is the one the panel adds, already containing every node.

Country groups, no defaults

With subClashNoDefGrp enabled, so only these groups exist:

mode: rule

proxy-groups:
  - name: Proxy
    type: select
    proxies:
      - Auto
      - Germany
      - Netherlands
      - DIRECT
  - name: Auto
    type: url-test
    filter: ".*"
    url: http://www.gstatic.com/generate_204
    interval: 300
  - name: Germany
    type: url-test
    filter: "(?i)de|germany"
    url: http://www.gstatic.com/generate_204
    interval: 300
  - name: Netherlands
    type: url-test
    filter: "(?i)nl|amsterdam"
    url: http://www.gstatic.com/generate_204
    interval: 300

rules:
  - GEOIP,Private,DIRECT
  - MATCH,Proxy

Proxy lists other groups by name, and each country group pulls its own nodes with a filter — which is why nothing here needs subClashSprtAll.

Extending the default groups

Without subClashNoDefGrp, naming a default group lets you change it rather than replace it:

proxy-groups:
  - name: Proxy
    type: select
    proxies:
      - DIRECT

Proxy still receives Auto and every node from the panel; DIRECT is appended as an extra choice.


Verifying the result

Download it and look at what you got:

curl -o config.yaml "http://<your server>:2096/sub/<client name>?format=clash"

Check that proxies contains the nodes you expect and that every group named in rules exists in proxy-groups. Mihomo can verify the file itself:

mihomo -t -f config.yaml

A group that ends up empty usually means its filter matched no tags — test the expression against the node names shown in the panel.

Clone this wiki locally