配置Nginx支持长轮询
配置Nginx支持长轮询
March 25, 2021
某些web应用需要使用到长轮询,在Nginx中需要添加配置来支持。比如说vaadin界面,如果没有做一些额外的配置,使用nginx做反向代理,会出现页面一直在加载的问题
首先需要在http中添加map块
map $http_upgrade $connection_upgrade {
default Upgrade;
'' close;
}
然后在location中添加下面的配置,使用刚才定义的内容
location /chat {
proxy_pass https://192.168.67.100:8443/chatapi;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_buffering off;
proxy_ignore_client_abort off;
break;
}
最后更新于