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