mihomo 代理客户端

test

IP rule result		curl -x http://127.0.0.1:7890 https://ipinfo.io
DNS result			curl -x http://127.0.0.1:7890 -I https://www.google.com
Lan share			curl -x http://192.168.1.100:7890 https://api.ipify.org

预下载geo文件

cd /www/clash
http_proxy=http://x99.kc.com:7890 wget -O ./data/geoip.dat https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat
http_proxy=http://x99.kc.com:7890 wget -O ./data/geosite.dat https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat
http_proxy=http://x99.kc.com:7890 wget -O ./data/country.mmdb https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb

docker-compose.yml

# ==============================================================================
# clash (mihomo) + clash-ui  ——  max2
#
# 运行方式(重要):
#   本机 NixOS 同时开了 rootful 和 rootless 两个 docker daemon。
#   这个 stack 应该跑在 **rootless(用户 cat)** 上:
#       docker compose up -d
#   当前实际是跑在 **rootful(system)** 上的(system.slice/docker-*.scope),
#   迁移:先 sudo docker compose down,再用普通用户 docker compose up -d。
#
# 资源限制:原来是 cpus 0.5 / mem_limit 256M —— 半核会成为 TLS 解密 +
#   多并发的天花板(实测单节点可跑 5MB/s,多客户端并发时 CPU 会顶住);
#   256M 对 35 节点订阅也偏紧。下面已放宽。
# ==============================================================================
services:
  clash:
    image: metacubex/mihomo:v1.19.32
    container_name: clash
    restart: always
    volumes:
      - ./data:/root/.config/mihomo
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "0.0.0.0:7890:7890"       # 代理端口,局域网可用(保持 0.0.0.0 ✓)
      - "127.0.0.1:9091:9090"     # API 端口:只发布到宿主机回环(局域网/外网都碰不到 ✓)
    networks:
      - ghost_net
    mem_limit: 256M               # 原 256M
    cpus: 1.0                     # 原 0.5
    ulimits:                      # 连接多的时候文件描述符要够
      nofile:
        soft: 65535
        hard: 65535
    environment:
      - TZ=Asia/Shanghai
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    healthcheck:                  # 镜像内自带 busybox wget(已确认)
      test: ["CMD", "wget", "-qO-", "--timeout=3", "http://127.0.0.1:9090/version"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 15s
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  clash-ui:
    image: ghcr.io/metacubex/metacubexd:v1.247.0
    container_name: clash-ui
    restart: always
    depends_on:
      - clash
    environment:
      - TZ=Asia/Shanghai
      # 注意:这个值是被【浏览器】读取的,不是容器之间通信用的 ——
      # 必须是浏览器能访问到宿主机的地址。因为上面把 API 收到回环了,
      # 这里也必须是回环地址(浏览器侧读取)。换机器/换网段时直接改这一行。
      # 也可用 tailnet 名:http://max2-at.tail9e6317.ts.net:9091
      - DEFAULT_BACKEND_URL=http://127.0.0.1:9091
    ports:
      - "127.0.0.1:9090:80"       # 面板入口:只发布到宿主机回环(本机浏览器访问 ✓)
    networks:
      - ghost_net
    mem_limit: 256M
    cpus: 1.0                     # 原 0.5,纯静态站,无所谓;写 1.0 只为别再抢半核
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

networks:
  ghost_net:
    external: true

config.yaml

simple

githubmix