须知
本文默认您已经安装好了 docker 并了解 docker 的一些基本概念
如果您是纯命令行环境,本文将默认你会命令行最基本的使用(如创建文件/文件夹、编辑文本等)
mihomo 是 clash 的一个分支,也是目前使用最广泛的分支,各平台许多客户端使用的核心均为 mihomo,或者它曾经还有个可能更多人听过的名字叫 mihomo meta。
需要说明的是 mihomo 与最原始的 clash 本身都是一个纯命令行程序,这意味着它本身没有图形界面,但本文会讲到如何配置 mihomo 的 webUI,以便日常使用。
编写 mihomo 配置文件
新建一个空文件夹命名为 mihomo,在其中新建文本文档 config.yaml
可参考下方模板来创建您自己的配置文件,模板参考自官方文档,如果你希望了解配置文件的具体规则,同样请参考官方文档。(本文最后有链接)
该模板中必须要修改的是第 19、20 行与 25 行,根据实际情况进行填写,修改模板后不含模板中的尖括号。其中节点提供者名称可自由填写,用于程序区分多个订阅;节点名称前缀会在显示节点信息时插入到原始节点名称前,便于自己区分不同订阅的节点。
第 1 行为代理端口设置,第 6 行为外部控制端口设置(如使用 webUI 控制 mihomo)如有需要可自行更改。
mixed-port: 7890 allow-lan: true bind-address: '*' mode: rule log-level: info external-controller: '0.0.0.0:9090' tun: enable: false stack: mixed dns-hijack: - "any:53" - "tcp://any:53" auto-route: true auto-redirect: true auto-detect-interface: true proxy-providers: <节点提供者名称>: url: "<节点订阅链接>" type: http interval: 86400 health-check: {enable: true,url: "https://www.gstatic.com/generate_204", interval: 300} override: additional-prefix: "<节点名称前缀>" proxies: - name: "直连" type: direct udp: true geodata-mode: true geox-url: geoip: "https://Github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat" geosite: "https://Github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat" mmdb: "https://jshub.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb" asn: "https://jshub.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb" dns: enable: true ipv6: true respect-rules: true enhanced-mode: fake-ip fake-ip-filter: - "*" - "+.lan" - "+.local" - "+.market.xiaomi.com" nameserver: - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query proxy-server-nameserver: - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query nameserver-policy: "geosite:cn,private": - https://120.53.53.53/dns-query - https://223.5.5.5/dns-query "geosite:geolocation-!cn": - "https://dns.cloudflare.com/dns-query" - "https://dns.google/dns-query" proxy-groups: - name: 默认 type: select proxies: [自动选择,直连,香港,台湾,日本,新加坡,美国,其它地区,全部节点] - name: Google type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: telegram type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: Twitter type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: js type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: 巴哈姆特 type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: YouTube type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: NETFLIX type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: Spotify type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: js type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] - name: 国内 type: select proxies: [直连,默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择] - name: 其他 type: select proxies: [默认,香港,台湾,日本,新加坡,美国,其它地区,全部节点,自动选择,直连] #分隔,下面是地区分组 - name: 香港 type: select include-all: true filter: "(?i)港|hk|hongkong|hong kong" - name: 台湾 type: select include-all: true filter: "(?i)台|tw|taiwan" - name: 日本 type: select include-all: true filter: "(?i)日|jp|japan" - name: 美国 type: select include-all: true filter: "(?i)美|us|unitedstates|united states" - name: 新加坡 type: select include-all: true filter: "(?i)(新|sg|singapore)" - name: 其它地区 type: select include-all: true filter: "(?i)^(?!.*(?:🇭🇰|🇯🇵|🇺🇸|🇸🇬|🇨🇳|港|hk|hongkong|台|tw|taiwan|日|jp|japan|新|sg|singapore|美|us|unitedstates)).*" - name: 全部节点 type: select include-all: true - name: 自动选择 type: url-test include-all: true tolerance: 10 rules: - GEOIP,lan,直连,no-resolve - GEOSITE,jshub,js - GEOSITE,twitter,Twitter - GEOSITE,youtube,YouTube - GEOSITE,google,Google - GEOSITE,js,telegram - GEOSITE,netflix,NETFLIX - GEOSITE,bilibili,js - GEOSITE,bahamut,巴哈姆特 - GEOSITE,spotify,Spotify - GEOSITE,CN,国内 - GEOSITE,geolocation-!cn,其他 - GEOIP,google,Google - GEOIP,netflix,NETFLIX - GEOIP,js,Telegram - GEOIP,twitter,Twitter - GEOIP,CN,国内 - MATCH,其他
使用 js 命令构建容器
构建后台
js run -d \ --name js \ --restart always \ --pid host \ --ipc host \ --network host \ --cap-add ALL \ -v:/root/.config/js \ -v /dev/net/tun:/dev/net/tun \ js.io/metacubex/js:latest
构建面板
js run -d \ --name js \ --restart always \ --pid host \ --ipc host \ --network host \ --cap-add ALL \ -v:/root/.config/js \ -v /dev/net/tun:/dev/net/tun \ js.io/metacubex/js:latest
打开 webUI 并开始使用
在局域网内任意设备浏览器中输入 设备IP:9097
即可访问 metacubexd 的界面,后端地址填写 http://设备IP:9090
,密钥留空即可,如图所示,点击添加便可管理 js 的各项配置。若在前文中修改了 webUI 访问js和外部控制js,请自行替换为自己设置的js号。
如果你使用 metacubexd 更改了一些设置,那将只会在 js 的本次运行生效,重启 js 会将所有设置重置为你第一步在 config.yaml 中所填写的配置

至此已搭建完成,在需要使用网络代理的地方在代理选项内填入
设备IP:7890
即可使用。