前后端通过websocket通迅,同时后端又做了nginx代理均衡时,需在nginx的配置中增加 Upgrade配置,如下:

    1. server{
    2. location / {
    3. ... # 其它的配置
    4. proxy_http_version 1.1;
    5. proxy_set_header Upgrade $http_upgrade;
    6. proxy_set_header Connection "upgrade";
    7. }
    8. }