nginx设置websocket代理

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# 有关说明参阅:nginx教程:map $http_upgrade $connection_upgrade升级连接配置解读-CSDN博客

server {
listen 8002;
server_name localhost;
location / {
proxy_pass http://192.168.122.18:8002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
#proxy_set_header Connection keep-alive;
proxy_set_header Host $host:$server_port;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
proxy_pass http://192.168.122.18:8002; 用来指定要被代理的websocket地址

nginx设置websocket代理
OdooBot April 21, 2024
Share this post
Tags
Archive
docker实用工具:runlike、whaler