欢迎光临
我们一直在努力

ruby-on-rails – Nginx在60秒后完全超时

本站教程收集整理的这篇文章主要介绍了ruby-on-rails – Nginx在60秒后完全超时,本站教程本站觉得挺不错的,现在分享给大家,也给大家做个参考。

我在后端(与Puma的Rails)绑定到unix套接字的app服务器
这是Nginx配置的相关部分

LOCATIOn /live/ {
 proxy_pass http://app; # match the name of upstream directive which is defined above
 proxy_set_header Host $host;
 proxy_set_header X-ForWARDed-For $proxy_add_x_forWARDed_for;
 proxy_redirect off;
 proxy_set_header Connection 'Upgrade';
 proxy_http_version 1.1;
 chunked_transfer_encoding off;
 send_timeout 300;
 proxy_send_timeout 300;
 keepalive_timeout 7200;
}

SSE事件来自/ live /,因此我调整了ngix配置来处理对此路由的所有请求.

问题是连接在60秒后完全关闭.这是我在响应头中看到的内容

Cache-Control:no-cache
Connection:keep-alive
Content-Type:text/event-stream
Date:Mon, 04 Nov 2013 13:41:52 GMT
Server:Nginx
X-Content-Type-Options:nosniff
x-frame-options:SAMEORIGIN
X-request-Id:7065a7bc-3450-4fe2-b60c-33dfa8d41951
X-Runtime:0.010852
X-UA-Compatible:chrome=1
X-XSS-Protection:1; mode=block

所以似乎Nginx将初始响应设置为close.为什么keepalive_timeout在这里不起作用.

在Nginx error.log中我看到了

2013/11/04 13:42:52 [error] 3689#0: *9 upstream timed out (110: Connection timed out)   while reading upstream, client: ......., server: myapp.com, request: "GET /live/events http/1.1", upstream: "http://unix:/home/ubuntu/myapp/shared/sockets/puma.sock:/live/events", host: "myapp.com"

解决方法:

为了防止其他人遇到Nginx Puma Rails的Timeout错误,Nginx中的以下配置应该将超时时间增加到605秒(10分5秒):

server {
    # ... here goes your proxy configuration

    # Avoid 504 http Timeout Errors
    proxy_connect_timeout       605;
    proxy_send_timeout          605;
    香港vps proxy_read_timeout          605;
    send_timeout                605;
    keepalive_timeout           605;
}

本站总结

以上是本站教程为你收集整理的ruby-on-rails – Nginx在60秒后完全超时全部内容,希望文章能够帮你解决ruby-on-rails – Nginx在60秒后完全超时所遇到的程序开发问题。

如果觉得本站教程网站内容还不错,欢迎将本站教程推荐给好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。