【发布时间】:2013-09-15 10:40:46
【问题描述】:
我让 Puma 作为上游应用服务器运行,Riak 作为我的后台数据库集群。当我发送一个请求,该请求为大约 25K 用户减少一大块数据并将其从 Riak 返回到应用程序时,我在 Nginx 日志中收到错误:
读取时上游超时(110:连接超时) 来自上游的响应头
如果我在没有 nginx 代理的情况下直接查询我的上游,使用相同的请求,我会得到所需的数据。
一旦放入代理就会发生Nginx超时。
**nginx.conf**
http {
keepalive_timeout 10m;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
include /etc/nginx/sites-enabled/*.conf;
}
**virtual host conf**
upstream ss_api {
server 127.0.0.1:3000 max_fails=0 fail_timeout=600;
}
server {
listen 81;
server_name xxxxx.com; # change to match your URL
location / {
# match the name of upstream directive which is defined above
proxy_pass http://ss_api;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache cloud;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
proxy_cache_bypass $http_authorization;
proxy_cache_bypass http://ss_api/account/;
add_header X-Cache-Status $upstream_cache_status;
}
}
Nginx 有一堆超时指令。我不知道我是否遗漏了一些重要的东西。任何帮助将不胜感激......
【问题讨论】:
-
它应该只在 600 秒后超时是吗?您可以通过在 127.0.0.1:3000 上设置一个 tcp 服务器来伪造它来计时,该服务器只接受连接并且不对其进行任何操作,以查看需要多长时间。应该是600s...