nginx+Vaadin的特殊性在於配置WEBSOCKET或LONG_POLLING。網上資料很少,本身屢次嘗試配置都不成功,後來終於找到這篇說明才得以配置成功,使用效果不錯,介紹以下。html
一、/etc/nginx/nginx.confnginx
map $http_upgrade $connection_upgrade { default Upgrade; '' close; }
二、/etc/nginx/conf.d/default.confgit
server { location / { proxy_pass http://localhost:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_buffering off; proxy_ignore_client_abort off; proxy_read_timeout 84600s; # 1 day proxy_send_timeout 84600s; # 1 day #break; } }
完成配置,重啓nginx便可。github
另請參見:http://atmosphere-framework.2306103.n4.nabble.com/Nginx-and-Atmosphere-td4119410.htmlspa