云驹博客

路漫漫其修远兮,吾将上下而求索。

0%

Nginx反向代理websocket

Nginx 反向代理 websocket

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

server {
listen 80;
listen [::]:80;
server_name yunjv.net;

location ~ .*$ {
proxy_set_header Host $http_host;
proxy_pass http://192.168.1.20:20010;
# 下面两条为关键配置
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}