Nginx配置支持websocket 或者其他Upgrade
在搭建jumpserver的时候,搭建完成后 通过nginx做端口代理。出现 "Connect websocket server error"的错误,后查询是nginx在代理websocket的时候需要加如下配置
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}
}
}
测试加上配置后 重启nginx jumpserver可以使用。不会报错