1

我设置了一个 Ionic 应用程序,它使用该ngx-socket-io模块连接到https://my-url.co.uk

然后我设置了一个使用 pm2 设置的 NestJS Web 服务器,并具有以下 nginx 配置:

server {
    listen      %ip%:%proxy_ssl_port% ssl;
    server_name %domain_idn% %alias_idn%;
    ssl         on;
    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;
    error_log  /var/log/httpd/domains/%domain%.error.log error;

    location / {
        proxy_pass      https://%ip%:3050;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;

        location ~* ^.+\.(%proxy_extentions%)$ {
            root           %sdocroot%;
            access_log     /var/log/httpd/domains/%domain%.log combined;
            access_log     /var/log/httpd/domains/%domain%.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

        location /error/ {
                alias   %home%/%user%/web/%domain%/document_errors/;
        }

    location @fallback {
        proxy_pass      https://%ip%:3050;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/snginx.%domain%.conf*;
}

该应用程序似乎能够正常连接,但在出现此错误后恢复为轮询:

WebSocket connection to 'wss://<my-url>.co.uk/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

有人能告诉我如何解决这个问题吗?我已经尝试了在网上找到的各种解决方案,但运气不佳!

谢谢你的帮助。

4

0 回答 0