解决nginx转发websocket
在 nginx.conf加入以下配置

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60;
proxy_read_timeout 600;
proxy_send_timeout 600;
nginx -s reload
如果nginx配置了多个监听端口代理
reload 会报下面错误
nginx: [warn] could not build optimal proxy_headers_hash, you should increase either proxy_headers_hash_max_size: 512 or proxy_headers_hash_bucket_size: 64; ignoring proxy_headers_hash_bucket_size
需要在http{
#加上这两行
proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
}