# df-relay 跨端 WS 中继反向代理(miniapp ↔ 桌面端)
# wss 在 nginx 终止(复用 *.1216.top 通配符证书),明文 ws 转 df-relay :9180

# HTTP → HTTPS 重定向
server {
    listen 80;
    server_name u-work.1216.top;
    return 301 https://$host$request_uri;
}

# HTTPS wss 反代
server {
    listen 443 ssl;
    server_name u-work.1216.top;

    include /etc/nginx/snippets/ssl-1216.conf;

    # df-relay 两个 WS 端点原样转发(/ws/device + /ws/miniapp)
    # proxy_pass 不带路径后缀 → 完整 URI 透传给 df-relay
    location /ws/ {
        proxy_pass http://127.0.0.1:9180;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_read_timeout 86400;
        proxy_send_timeout 86400;
    }
}
