Skip to content

設定總覽

最小骨架

yaml
mixed-port: 7890
allow-lan: false
mode: rule
log-level: info

dns:
  enable: true
  enhanced-mode: fake-ip
  nameserver:
    - system

proxies: []
proxy-groups: []
rules:
  - MATCH,DIRECT

完整帶註解範例:config.yaml

General

欄位用途
portHTTP proxy port
socks-portSOCKS5 port
mixed-portHTTP/SOCKS 共用 port
redir-portRedir transparent proxy port
tproxy-portLinux TProxy TCP/UDP port
allow-lan是否允許非 loopback client
bind-addressLAN listener bind address
moderuleglobaldirect
log-levelsilenterrorwarninginfodebug
ipv6啟用 IPv6 resolution/routing
interface-name預設出站 interface
routing-markLinux socket mark
find-process-modealwaysstrictoff
tcp-concurrent對解析出的 IP 並行建立 TCP
unified-delay統一 delay test 計算

Mode

  • rule:依序比對 rules
  • global:所有流量交給 GLOBAL group。
  • direct:所有流量直接送出。

Rule mode 沒有任何規則命中時會回落 DIRECT,仍建議明確加入:

yaml
rules:
  - MATCH,FINAL

並確保 FINAL 是存在的 proxy/group 名稱。

Controller

yaml
external-controller: 127.0.0.1:9090
external-controller-tls: 127.0.0.1:9443
external-controller-unix: mihomo.sock
external-controller-pipe: \\.\pipe\mihomo
secret: "replace-with-a-strong-secret"
欄位說明
external-controllerHTTP Controller
external-controller-tlsHTTPS Controller,使用 tls 憑證
external-controller-unixUnix socket;Windows 新版也可能支援
external-controller-pipeWindows named pipe
external-controller-routing-markLinux listener routing mark
external-controller-corsOrigin 與 private-network CORS
external-uiUI directory
external-ui-urlUI archive URL
external-doh-serverController 上的 DoH path

非空白 secret 會保護一般 Controller API。靜態 /ui、Aster subscription 與可選 DoH route 不在同一 authentication group。

TLS

Controller TLS 與部分共用憑證設定使用:

yaml
tls:
  certificate: ./server.crt
  private-key: ./server.key
  client-auth-type: ""
  client-auth-cert: ""

Certificate 可是 PEM 內容或安全路徑內的檔案。啟用 mTLS verification 時必須提供 client CA/cert。

Proxies 與 groups

yaml
proxies:
  - name: edge
    type: vless
    server: proxy.example.com
    port: 443
    uuid: 00000000-0000-0000-0000-000000000000
    tls: true
    servername: proxy.example.com

proxy-groups:
  - name: PROXY
    type: select
    proxies:
      - edge
      - DIRECT

詳細欄位見出站與代理群組

Providers

yaml
proxy-providers:
  remote:
    type: http
    url: https://example.com/subscription.yaml
    path: ./providers/remote.yaml
    interval: 3600
    health-check:
      enable: true
      url: https://www.gstatic.com/generate_204
      interval: 300

Provider path 同樣受 safe-path 檢查。遠端內容應視為不可信設定,限制來源並使用 HTTPS。

Listeners

listeners 用於額外 server inbound:

yaml
listeners:
  - name: local-socks
    type: socks
    listen: 127.0.0.1
    port: 1080

每個 listener 必須有唯一 name。詳情見入站參考

Aster

yaml
aster:
  secret: "replace-with-at-least-32-random-bytes"
  public-base-url: https://proxy.example.com
  store: aster-state.json
  managed-listeners:
    - edge-vless

只要存在 aster block 就會啟用 Aster manager。完整說明見Aster 管理概覽

TUN

yaml
tun:
  enable: true
  stack: gvisor
  auto-route: true
  auto-detect-interface: true
  dns-hijack:
    - any:53

Release build 已包含 with_gvisor。TUN 的 route、auto-redirect、UID/package include/exclude 及平台差異很多,請先在目標平台用最小設定驗證。

Profile 與 cache

Profile cache 可保存 selected proxy、fake-IP 與 provider subscription information。預設 cache file 位於 home directory 的 cache.db

不要把 Aster state 與 profile cache 混為一談:

  • cache.db:Mihomo runtime/profile cache。
  • aster-state.json:Aster managed users、traffic、revision 與 subscriptions。