mihomo 订阅模板
mihomo(原 Clash Meta)是 Clash 家族的内核。它接受 YAML 格式的 订阅,并据此自行构建配置:选择本地端口、DNS 和工作 模式。请务必记住:只有 Meta 内核支持 VLESS+Reality(mihomo、 clash-meta),经典 Clash Premium 无法识别这种订阅。
YAML 结构
| 小节 | 用途 |
|---|---|
mixed-port | 同时用于 HTTP 和 SOCKS 的本地端口 |
allow-lan, mode, log-level | 基本工作模式 |
dns | 内核的 DNS 解析器 |
proxies | 服务器列表(每个 inbound 一个) |
proxy-groups | 选择组:自动或手动 |
rules | 路由规则 |
代理
proxies 块重复你 Xray 中 inbound 的参数。VLESS+Reality+Vision
的示例:
proxies:
- name: "MyServer-Reality"
type: vless
server: 203.0.113.10
port: 443
uuid: 11111111-2222-3333-4444-555555555555
udp: true
network: tcp
tls: true
flow: xtls-rprx-vision
servername: www.microsoft.com
client-fingerprint: chrome
reality-opts:
public-key: REALITY_PUBLIC_KEY
short-id: "ab12"
面向旧内核的备用方案 VLESS+WS+TLS 在传输方式上有所不同:
proxies:
- name: "MyServer-WS"
type: vless
server: 203.0.113.10
port: 443
uuid: 11111111-2222-3333-4444-555555555555
udp: true
network: ws
tls: true
servername: sub.example.com
client-fingerprint: chrome
ws-opts:
path: /ws
headers:
Host: sub.example.com
| mihomo 字段 | VLESS 的取值 |
|---|---|
type | 始终为 vless |
server, port | 来自 vnext 的地址和端口 |
uuid | 用户的 id |
udp | 启用 UDP 传输 |
network | Reality 用 tcp,WebSocket 用 ws |
tls | 两种情况下均为 true |
flow | Reality 用 xtls-rprx-vision |
servername | SNI(伪装域名) |
client-fingerprint | TLS 指纹,通常为 chrome |
reality-opts | Reality 的 public-key 和 short-id |
ws-opts | WebSocket 的 path 和 Host 请求头 |
uuid 是用户的凭据。不要发布 YAML,也不要在公开聊天中
转发它:拿到它的人就能以你的身份连接到你的服务器。
Proxy-groups
分组决定使用哪台服务器。url-test 自动选择
最快的一台,select 提供手动选择:
proxy-groups:
- name: AUTO
type: url-test
url: https://www.gstatic.com/generate_204
interval: 300
tolerance: 50
proxies:
- MyServer-Reality
- MyServer-WS
- name: PROXY
type: select
proxies:
- AUTO
- MyServer-Reality
- MyServer-WS
在 select 组中同时保留 AUTO 和各个单独的服务器:当
自动检查失败时,用户可以手动切换。
Rules
最小规则集会放行本地网络直连,其余全部 走代理:
rules:
- GEOIP,LAN,DIRECT
- MATCH,PROXY
规则列表可按需扩展:面板中的路由规则 在 路由规则 一节中说明。
从 Xray 配置代入
如果你有 Xray 客户端配置,字段可以一一对应地搬到 mihomo:
| Xray(客户端 JSON) | mihomo |
|---|---|
outbounds[].settings.vnext[].address | server |
outbounds[].settings.vnext[].port | port |
outbounds[].settings.vnext[].users[].id | uuid |
users[].flow | flow |
streamSettings.network | network |
streamSettings.security | tls: true + reality-opts |
realitySettings.serverName | servername |
realitySettings.publicKey | reality-opts.public-key |
realitySettings.shortId | reality-opts.short-id |
realitySettings.fingerprint | client-fingerprint |
wsSettings.path | ws-opts.path |
wsSettings.headers.Host | ws-opts.headers.Host |
例如,客户端配置片段
{
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "203.0.113.10",
"port": 443,
"users": [{ "id": "11111111-2222-3333-4444-555555555555", "flow": "xtls-rprx-vision" }]
}
]
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"serverName": "www.microsoft.com",
"publicKey": "REALITY_PUBLIC_KEY",
"shortId": "ab12",
"fingerprint": "chrome"
}
}
}
]
}
会原样变成上面示例中的第一个 proxy。
它如何进入客户端
不要向用户下发一份通用的 JSON 配置:那样就必须固化
特定应用程序的本地端口和 DNS。请下发订阅链接 ——
这样每个应用程序都会为自己构建配置。Clash/mihomo/Stash 家族的
客户端会自行请求 YAML:订阅服务器根据 User-Agent
请求头判断格式,并另外通过 Profile-Update-Interval 请求头
告知自动更新间隔。
同一个订阅在所有地方都能用:mihomo 获得 YAML,基于 Xray-core 的客户端获得带链接的 base64。无需按客户端拆分订阅。