AnydoDocs
自托管

HTTPS 与反向代理

使用 nginx 或 OpenResty 正确代理 Anydo Hub、SSE 和 Socket.IO。

Anydo Hub 同时使用普通 HTTP、SSE 长连接和 Socket.IO。代理配置必须支持连接升级和长时间读取。

nginx 示例

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 443 ssl;
    server_name hub.example.com;

    ssl_certificate     /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:3006;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 86400s;
    }
}

必须检查

  • Connection 使用 $connection_upgrade,不要直接使用 $http_connection
  • HTTPS 证书覆盖 Hub 域名
  • WebSocket Upgrade 没有被 CDN 或 WAF 删除
  • /api/events SSE 不被代理缓冲或短超时中断
  • CORS_ORIGINS 包含真实 Dashboard 来源
  • 代理传递正确的 HostX-Forwarded-Proto

Socket.IO 兼容

使用较旧 nginx 且启用 HTTP/2 时,可以让客户端先用 polling,再升级 WebSocket,降低握手兼容问题。

验证

curl -fsS https://hub.example.com/health
curl -fsS https://hub.example.com/api/hub/info

/health 用于存活检查;/api/hub/info 是公开发现接口,不应替代健康探针。

本页内容