问题的可能原因是,由于使用了Nginx代理,WebSockets协议的访问被阻止了。如果您使用的是Blazor服务器则需要使WebSocket可以在Nginx上使用。
以下是使用WebSocket在Nginx上使用Blazor服务器的样例代码:
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /path/to/cert;
ssl_certificate_key /path/to/key;
location / {
proxy_pass https://localhost:1234;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /ws {
proxy_pass https://localhost:1234;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_cache_bypass $http_upgrade;
}
}
使用上述代码,可以在您的Nginx配置中添加位置/WS部分,该部分将使用代理将标头设置为“连接”和升级”。
此外,您需要确保在应用程序中已经配置了适当的WebSocket支持。
您的问题应该可以通过使用此样例代码并正确配置您的应用程序来解决。