WARP Team + sing-box 配置指南

Cloudflare WARP Zero Trust 代理模式 + sing-box VLESS-REALITY 完整配置记录

📋 目录

  1. 架构说明
  2. WARP 注册与认证
  3. WARP 关键配置
  4. sing-box 配置文件
  5. 验证命令
  6. Clash Verge 配置说明
  7. 故障排查
  8. 日常维护

🏗️ 架构说明

流量链路如下:

Windows Clash (TUN/mixed) 
    → VPS sing-box :443 (VLESS-REALITY)
        ├─ anthropic.com / claude.ai / openai.com / chatgpt.com
        │      → WARP Proxy 127.0.0.1:40000 → Cloudflare Zero Trust → 目标
        └─ 其他流量
               → direct → 目标
ℹ️ WARP 运行在 WarpProxy 模式 (port 40000),不接管服务器全局流量,仅作为 sing-box 的出站代理使用。

🔑 WARP 注册与认证

重新注册流程

1

删除旧注册,发起新注册(替换为你的 Zero Trust 组织名)

# 删除旧注册
warp-cli registration delete

# 发起新注册
warp-cli --accept-tos registration new YOUR_ORG_NAME
2

命令执行后浏览器会打开认证页面,认证成功后浏览器会尝试跳转到:

com.cloudflare.warp://YOUR_ORG.cloudflareaccess.com/auth?token=XXXXXX

复制 token= 后面的完整字符串

3

在服务器上手动传入 token(因为浏览器在 Windows,token 不会自动传回服务器)

warp-cli registration token XXXXXX
4

设置代理模式并连接

warp-cli mode proxy
warp-cli proxy port 40000
warp-cli connect
warp-cli status
⚠️ 注意:浏览器需要在能打开认证页面的设备上操作,服务器上不能直接完成浏览器认证,必须手动传 token。

⚙️ WARP 关键配置

Zero Trust 后台必要设置

路径:Zero Trust 后台 → Team & Resources → Devices → Device profiles → Default

设置项说明
Service modeLocal proxy mode必须设为此模式,否则无法切换为 proxy
Allow Mode Switchtrue允许客户端切换模式

当前 WARP 配置状态(正常)

Mode:         WarpProxy on port 40000   # 代理模式,不接管全局流量
Always On:    true                      # 断线自动重连
Auto Connect: 3                         # 开机自动连接
Organization: Your Team Name            # Zero Trust 组织
Protocol:     MASQUE (HTTP/3)           # 连接协议

📦 sing-box 配置文件

配置文件路径:/etc/sing-box/config.json

{
  "log": { "level": "info" },
  "inbounds": [
    {
      "type": "vless",
      "tag": "vless-reality-in",
      "listen": "::",
      "listen_port": 443,
      "users": [{ "uuid": "YOUR_UUID", "flow": "" }],
      "tls": {
        "enabled": true,
        "server_name": "www.microsoft.com",
        "reality": {
          "enabled": true,
          "handshake": { "server": "www.microsoft.com", "server_port": 443 },
          "private_key": "YOUR_PRIVATE_KEY",
          "short_id": ["YOUR_SHORT_ID"]
        }
      }
    }
  ],
  "outbounds": [
    {
      // OpenAI / Claude 走 WARP 代理
      "type": "socks",
      "tag": "warp-out",
      "server": "127.0.0.1",
      "server_port": 40000,
      "version": "5"
    },
    { "type": "direct", "tag": "direct" },
    { "type": "block", "tag": "block" }
  ],
  "route": {
    "rules": [
      {
        "domain_suffix": [
          "anthropic.com",
          "claude.ai",
          "openai.com",
          "chatgpt.com",
          "oaiusercontent.com"
        ],
        "outbound": "warp-out"
      }
    ],
    "final": "direct"
  }
}

sing-box 服务管理

# 重启服务
systemctl restart sing-box

# 查看状态
systemctl status sing-box

# 查看实时日志
journalctl -u sing-box -f

# 验证配置文件语法
sing-box check -c /etc/sing-box/config.json

验证命令

验证 WARP 状态

# 查看连接状态
warp-cli status

# 确认走了 WARP
curl --socks5-hostname 127.0.0.1:40000 \
  https://cloudflare.com/cdn-cgi/trace \
  | grep -E "warp|ip"

# 期望输出:
# ip=104.x.x.x  (WARP IP)
# warp=on

验证目标站点可达

# 测试 Claude(期望 302)
curl --socks5-hostname 127.0.0.1:40000 \
  -I https://claude.ai

# 测试 OpenAI(期望 308)
curl --socks5-hostname 127.0.0.1:40000 \
  -I https://chat.openai.com

# 测试服务器直连 Google
curl -I https://www.google.com

🐱 Clash Verge 配置说明

⚠️
TUN 模式必须使用 mixed 或 system Stack
安装 WARP 后,WARP 会创建虚拟网络接口 CloudflareWARP
Clash TUN 的 gvisor 模式有独立用户态网络栈,无法识别该接口导致冲突。
mixed / system 模式使用系统原生网络栈,可正确处理 WARP 虚拟接口。
TUN Stack 模式安装 WARP 后可用说明
gvisor❌ 冲突用户态网络栈,与 WARP 虚拟接口冲突
mixed✅ 正常推荐使用
system✅ 正常可用

修改方式

Clash Verge → 设置 → TUN 模式 → Stack → 改为 mixed

🔧 故障排查

问题原因解决方案
Registration Missing due to Manual deletion 注册被删除 重新执行注册流程,手动传入 token
warp-cli mode proxy 报 Invalid setting Zero Trust 策略限制 后台 Device profile → Service mode 改为 Local proxy mode
WARP 接管全局流量导致 Clash 断连 WARP 处于 Tunnel 模式 切换为 proxy 模式:warp-cli mode proxy
Clash TUN 模式无法访问网络 gvisor 与 WARP 虚拟接口冲突 TUN Stack 改为 mixed
claude.ai 返回 403 服务器 IP 被封,未走 WARP 确认 sing-box 规则和 WARP 连接状态

策略刷新命令

# 断开重连以刷新 Zero Trust 策略
warp-cli disconnect
sleep 5
warp-cli connect
sleep 5
warp-cli mode proxy
warp-cli proxy port 40000
warp-cli status

🛡️ 日常维护

配置完成后基本无需维护,以下为偶尔检查项。

检查服务状态

# WARP 状态
warp-cli status

# sing-box 状态
systemctl status sing-box

# WARP 服务状态
systemctl status warp-svc

注意事项

# Zero Trust 免费版限制
# - 最多 50 个设备
# - 无流量限制

# 开机自启已配置
# - warp-svc: 自动启动
# - sing-box: systemctl enabled