linux nginx dotnet 核心应用信号器无法通过 ssl 工作

linux nginx dotnet core app signalr not working over ssl

这在测试应用程序时有效。当我将 DNS 切换到服务器然后添加 SSL 证书时,signalR 停止工作(我的聊天)。我认为这与现在重定向到端口 443 的代理有关。网站的其余部分可以正常工作,只是聊天功能不行。

Firefox can’t establish a connection to the server at wss://www.my-website.com/chatHub?id=qDsSrV-APYXpnyk_EfsrXw. signalr.min.js:16:110126
Uncaught (in promise) Error: Server returned handshake error: Handshake was canceled.

和nginx中的配置:

server {
    server_name www.my-website.com;
    location / {
        proxy_pass         http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/www.my-website.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.my-website.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    }

}
server {
    if ($host = www.my-website.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen        80;
    server_name www.my-website.com;
    return 404; # managed by Certbot
}

如能提供任何有关让 signalR 重新工作的帮助,我们将不胜感激,谢谢。

所以,事实证明,当 Certbot 编辑配置时,它添加了一个额外的不必要的 }。这就是打破它的全部。配置已损坏并提供缓存状态。所以我通过 https:// 查看网站,但试图在端口 80 上建立 websocket 连接,但失败了,因为它不安全。