我遵循了401-ActionController-Live Railscast和这篇Blog Post关于
我还尝试了按照以下问题提供的解决方案,但对我不起作用:
Server-Sent-Events
的内容,在我的Rails应用程序中设置了类似的东西。当我只使用puma
时,它可以完美地工作,但是使用puma + nginx
时,连接在发送第一个数据块后就会关闭。我还尝试了按照以下问题提供的解决方案,但对我不起作用:
- ActionController::Live Streaming dies after first chunk sent
- EventSource / Server-Sent Events through Nginx
nginx
配置:upstream puma {
server unix:///home/deploy/apps/outy/shared/tmp/sockets/outy-puma.sock;
keepalive 16;
}
server {
listen 80 default_server deferred;
root /home/deploy/apps/outy/current/public;
access_log /home/deploy/apps/outy/current/log/nginx.access.log;
error_log /home/deploy/apps/outy/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
proxy_cache off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}