无法通过php-fpm增加nginx的超时时间

问题描述

我的Nginx拒绝将请求的超时时间从默认的60秒增加。

我已经设置了以下参数,但是服务器在60秒后仍给我504:

fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
client_header_timeout 300s;
client_max_body_size 200m;
client_body_timeout 300s;
send_timeout 300s;

足够有趣的是,将值设置为30秒即可,并且请求在30秒后超时。 PHP-fpm中的request_terminate_timeout也设置为300秒。

我需要设置哪些参数以使其超过60秒?

解决方法

您是否在“ http”部分的末尾添加了以下指令?

http {
    <...>
    include /etc/nginx/conf.d/.conf;

    proxy_send_timeout 180s;
    proxy_read_timeout 180s;
    fastcgi_send_timeout 180s;
    fastcgi_read_timeout 180s;
}

此后,您可能还需要重新启动nginx服务器。

为什么您没有任何改变的另一个可能原因是您可能编辑了错误的文件,但是我对此表示怀疑。 :)

要验证路径,nginx -tnginx -V都将打印出默认的nginx配置文件路径。

来源:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...