如何在Nginx上使用FastCGI防止网关超时 [英] How do I prevent a Gateway Timeout with FastCGI on Nginx

查看:691
本文介绍了如何在Nginx上使用FastCGI防止网关超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Django,FastCGI和Nginx。我创建一个api的类型,有人可以通过XML发送一些数据,我将处理,然后返回一些状态代码为每个发送的节点。

I am running Django, FastCGI, and Nginx. I am creating an api of sorts that where someone can send some data via XML which I will process and then return some status codes for each node that was sent over.

问题是,如果我花费太长的时间来处理XML,Nginx将抛出504网关超时 - 我想超过60秒。

The problem is that Nginx will throw a 504 Gateway Time-out if I take too long to process the XML -- I think longer than 60 seconds.

所以我想设置Nginx,以便如果任何匹配位置/ api的请求不会超时120秒。

So I would like to set up Nginx so that if any requests matching the location /api will not time out for 120 seconds. What setting will accomplish that.

我到目前为止是:

    # Handles all api calls
    location ^~ /api/ {
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        fastcgi_pass 127.0.0.1:8080;
    }

编辑:我所工作的不是:)

What I have is not working :)

推荐答案

代理超时适用于代理,不适用于FastCGI ...

Proxy timeouts are well, for proxies, not for FastCGI...

影响FastCGI超时的是 client_header_timeout client_body_timeout send_timeout

The directives that affect FastCGI timeouts are client_header_timeout, client_body_timeout and send_timeout.

编辑:考虑到nginx wiki中的内容, send_timeout指令负责设置响应的一般超时(这有点误导)。对于FastCGI,有 fastcgi_read_timeout 会影响 fastcgi进程响应超时

Edit: Considering what's found on nginx wiki, the send_timeout directive is responsible for setting general timeout of response (which was bit misleading). For FastCGI there's fastcgi_read_timeout which is affecting the fastcgi process response timeout.

HTH。

这篇关于如何在Nginx上使用FastCGI防止网关超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆