zhmg23

我们是如此的不同

配置nginx反向代理支持websocket

# 在nginx的http上下文中,增加如下配置,确保nginx也能处理正常http请求

map $http_upgrade $connection_upgrade {

default upgrade;

 '' close;

}


# 以下配置是在server上下文中添加,location指用于websocket连接的path


proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_set_header Host $host;


参考:

https://nginx.org/en/docs/http/websocket.html


评论