WebSocket connection to 'ws://.../sockjs/pushWords/635/78epgvv8/websocket'

聂鹏云
2023-12-01

Meteor WebSocket connection to 'ws://…/websocket' failed: Error during WebSocket handshake: Unexpected response code

在系统中加入WebSocket的时候,如果没有在nginx中配置允许websocket,是会提示错误

在nginx中加入

location / {
    proxy_pass http://localhost:8080;
    //加入如下几句话即可
    proxy_set_header Host $host; # pass the host header
    proxy_set_header Upgrade $http_upgrade; # allow websockets
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header X-Real-IP $remote_addr; # Preserve client IP
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_http_version 1.1;
  }

 类似资料: