如何解决nginx迁移插件中的connection_upgrade错误?详细解决方法

频道:服务器安全防护 日期: 浏览:141
蓝梯子海外云服务器

今天,客户在用宝塔api迁移插件的时候,迁移数据的时候突然出现错误 :nginx: unknown “connection_upgrade”,这是什么问题呢?

配置 “$connection_upgrade” 变量

连接升级通常与 WebSockets 结合使用。 在 nginx 中,我们可以根据 $http_upgrade 变量将 HTTP 连接升级为 WebSocket 连接。nginx配置文件出了问题,将下面map代码块补上即可。

如何解决nginx迁移插件中的connection_upgrade错误?详细解决方法

我们可以使用map块在nginx中定义连接和http升级之间的依赖关系:

vim nginx.conf

map $http_upgrade $connection_upgrade {

default upgrade;

如何解决nginx迁移插件中的connection_upgrade错误?详细解决方法

” close;

如果 Upgrade 标头设置为 ‘’,此 map 块告诉 nginx 正确设置相关的 Connection 标头来关闭连接。 将 map 块放入 nginx 配置的 http 块中。 nginx 配置的默认文件路径是 /etc/nginx/nginx.conf

 

蓝梯子海外云服务器