我在后端(与Puma的Rails)绑定到unix套接字的app服务器这是nginx配置的相关部分location /live/ {proxy_pass http://app; # match the name of upstream directive which is defined aboveproxy_set_header Host $hos...

我在后端(与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;
proxy_read_timeout 605;
send_timeout 605;
keepalive_timeout 605;
}
织梦狗教程
本文标题为:ruby-on-rails – Nginx在60秒后完全超时


基础教程推荐
猜你喜欢
- 浅析ELF转二进制允许把 Binary 文件加载到任意位置 2023-07-06
- win10下使用virtualbox + vagrant配置ruby开发机环境 2023-07-23
- Swift初始化器与可选链的使用方法介绍 2023-07-08
- Swift中重写和重载的使用与对比总结 2023-07-05
- Ruby3多线程并行Ractor使用方法详解 2023-07-23
- R语言-修改(替换)因子变量的元素操作 2022-11-26
- ruby on rails validates 2023-09-22
- R语言 ggplot2改变柱状图的顺序操作 2022-11-17
- R语言绘制折线图实例分析 2022-11-21
- ruby-on-rails-为使用Rails 4,nginx和乘客的用户设置自定义域 2023-09-21