NGINX 反向代理 WebSocket 配置说明。
配置
# 定义 WebSocket Upstream
upstream websocket {
server 127.0.0.1:2333;
}
server {
# ...
# 代理 WebSocket 请求
location /ws/ {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
# ...
}