NGINX 反向代理 WebSocket 配置說明。
配置
1# 定義 WebSocket Upstream
2upstream websocket {
3 server 127.0.0.1:2333;
4}
5
6server {
7 # ...
8
9 # 代理 WebSocket 請求
10 location /ws/ {
11 proxy_pass http://websocket;
12 proxy_http_version 1.1;
13 proxy_set_header Upgrade $http_upgrade;
14 proxy_set_header Connection "Upgrade";
15 }
16
17 # ...
18}