Ruby-on-rails nginx 504 网关超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6083020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
nginx 504 Gateway Time-out
提问by ben
I'm running a rails3.0.7 project with phusion-passenger on nginx. While I was doing a ajax which took about 15 mins to process. It jump up an error with firebug which said "504 Gateway Time-out" after 10 mins from calling the ajax.
我正在 nginx 上运行一个带有 phusion-passenger 的 rails3.0.7 项目。当我在做一个 ajax 时,大约需要 15 分钟来处理。在调用 ajax 10 分钟后,它跳出一个错误,说“504 网关超时”。
Could someon give me some idea of how I could find the problem.
有人可以给我一些关于如何找到问题的想法。
Thanks, ben
谢谢,本
environment
环境
- OS: mac osx 10.6.7
- ruby: 1.9.2p180 installed with rvm
- gem: 1.6.2
- passenger 3.0.7
- rails: 3.0.7
- mysql: 5.5.10 installed with brew
- nginx: 1.0.0 stand alone installed with passender
- 操作系统:mac osx 10.6.7
- ruby: 1.9.2p180 与 rvm 一起安装
- 宝石:1.6.2
- 乘客 3.0.7
- 导轨:3.0.7
- mysql: 5.5.10 安装了 brew
- nginx: 1.0.0 独立安装与 passender
采纳答案by Glenn Snyder
That's an nginx timeout error. Look at the following article for some clues as to which parameter you need to adjust to avoid the timeout, if you really want to allow more than 10 minutes to complete the task.
那是 nginx 超时错误。如果你真的想让10分钟以上的时间来完成任务,你需要调整哪个参数来避免超时,看看下面的文章有一些线索。
回答by Lalit Kumar Maurya
I had the similar issue with Rails 4 on Mac OS X (Yosemite). So I have added the below into my specific Nginx location.
我在 Mac OS X (Yosemite) 上的 Rails 4 也有类似的问题。所以我已将以下内容添加到我的特定 Nginx 位置。
proxy_connect_timeout 43200000;
proxy_read_timeout 43200000;
proxy_send_timeout 43200000;
So my overall configuration for Nginx as below.
所以我对 Nginx 的整体配置如下。
location /my_sub_path/ {
root /my/rails/project/public/folder/path
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
proxy_connect_timeout 43200000;
proxy_read_timeout 43200000;
proxy_send_timeout 43200000;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:3000/;
}
回答by sir
It's a problem from phusion-passenger. You should alter the file:(gems > passenger-3.0.18 > ext > nginx > Configuration.c)
这是phusion-passenger的问题。您应该更改文件:(gems >passenger-3.0.18 > ext > nginx > Configuration.c)
ngx_conf_merge_msec_value(conf->upstream_config.send_timeout,
prev->upstream_config.send_timeout, 6000000);
ngx_conf_merge_msec_value(conf->upstream_config.read_timeout,
prev->upstream_config.read_timeout, 6000000);
The origin timeout is 600000, just 10 minutes. I've tried to change the nginx.conf, but didn't work.
原点超时为 600000,仅 10 分钟。我试图更改 nginx.conf,但没有奏效。
回答by Shankar Banjara
That's an nginx timeout error.
那是 nginx 超时错误。

