map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}文章来源:https://www.toymoban.com/news/detail-539524.html
# 转发ws
location ^~ /ws {
# 后台准备的websocket地址端口
proxy_pass http://localhost:9092;
# 其他参数都一样
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}文章来源地址https://www.toymoban.com/news/detail-539524.html
到了这里,关于nginx代理websocket相关配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!