我正在尝试使用websocket连接到我的Nginx服务器。
我的Nginx.conf文件是:
http {
server {
listen 8080;
server_name www.easy-emdr.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass https://www.easy-emdr.com:8080/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
}
events{}
我的IP是占位符
我正在尝试通过(客户端)连接到它:
var socket = io.connect('https://11.11.111.11:8080', { transports: ['websocket'] });
在服务器端,我有:
server.listen(8080, () => {
console.log('listening on 8080');
});
我得到的错误是:
WebSocket connection to 'wss://11.11.111.11:8080/socket.io/?EIO=3&transport=websocket' failed: WebSocket is closed before the connection is established.
如果您能帮助我,我将永远爱您!