upstream apiv11 {
    server 127.0.0.1:8084;
    keepalive 64;
}

upstream chatws1 {
    server 127.0.0.1:8084;
    keepalive 64;
}

server {
    server_name  updsrv.szaiai.com;

    client_max_body_size 100M;

    location / {
        return 404;
    }

    # 普通 HTTP 请求处理，不支持 WebSocket
    location ^~/api/v1 {
        proxy_redirect off;
        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_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Connection "";
        proxy_http_version 1.1;
        proxy_pass http://apiv11;
    }

    # 仅此处启用 WebSocket 支持
    location ^~ /api/v1/deploy/ws/ {
        proxy_redirect off;
        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_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Connection "";
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://chatws1;
    }
}
