宝塔面板nginx设置长链接

moonjerx
2021-07-30 / 0 评论 / 310 阅读 / 正在检测是否收录...

在http{}内添加以下配置:

#自定义变量 $connection_upgrade
map $http_upgrade $connection_upgrade { 
  default      keep-alive;  #默认为keep-alive 可以支持 一般http请求
  'websocket'  upgrade;     #如果为websocket 则为 upgrade 可升级的。
}

在location / {}中添加以下配置:

#长连接通信start#
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; #此处配置 上面定义的变量
proxy_set_header Connection $connection_upgrade;
#长连接通信end#
0

评论 (0)

取消

您的IP: