nginx 和奇偶校验的 Websocket 连接?

Websocket connection for nginx and parity?

我是运行云服务器上的dAPP,使用nginx和奇偶校验客户端并启用了wesocket。

我为 https 域安装了 certbot 证书。 现在我遇到了问题,在使用 https 访问我的网站时,它在 chrome 上给出了一个错误...

  web3-providers.umd.js:1269 Mixed Content: The page at 'https://www. 
  chain.com/' was loaded over HTTPS, but attempted to connect to the 
 insecure WebSocket endpoint 'ws://40.138.47.154:7546/'. This request has 
   been blocked; this endpoint must be available over WSS.

然后我在 nginx 配置文件上添加了反向代理

location / {
         # switch off logging
   access_log off;

    proxy_pass http://localhost:7556; #Port for parity websocket
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # WebSocket 
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

然后它给出了

的错误

"WebSocket interface is active. Open WS connection to access RPC."

这里有什么问题,我应该尝试什么?

谢谢

https 不允许在页面上加载不安全的内容。

一种可能的解决方案是在应用程序服务器和客户端之间使用 SSL/TLS 终止符。

来自官方的Nginx docs,配置文件的相关部分可能是这样的:

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

upstream websocket {
    server localhost:7546;
}

server {
    listen 443; 
    
    location / {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
    }

    ssl on;
    # specify cert and key

}

在 dApp 内部将 'ws://40.138.47.154:7546/' 更改为 wss://40.138.47.154