nginx 出现504 Gateway Time-out 相关设置

87 篇文章 4 订阅

nginx配置

nginx.conf中,设置以下几个参数,增加超时时间

fastcgi_connect_timeout
fastcgi连接超时时间,默认60秒

fastcgi_send_timeout
nginx 进程向 fastcgi 进程发送请求过程的超时时间,默认值60秒

fastcgi_read_timeout
fastcgi 进程向 nginx 进程发送输出过程的超时时间,默认值60秒


php配置

php.ini

max_execution_time
php脚本最大执行时间
 
php-fpm

request_terminate_timeout
设置单个请求的超时时间

 
php程序中可加入set_time_limit(seconds)设置最长执行时间

nginx 三个代理超时时间配置

proxy_connect_timeout
proxy_send_timeout
proxy_read_timeout
我们先看下nginx官网对他们的解释:

proxy_connect_timeout 60s;

Defines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75
seconds. 定义与被代理服务器建立连接的超时时间。请注意,此超时通常不能超过75秒。

proxy_send_timeout dedault 60s

Sets a timeout for transmitting a request to the proxied server. The timeout is set only between two successive write operations, not for
the transmission of the whole request. If the proxied server does not
receive anything within this time, the connection is closed.
设置将请求传输到被代理服务器的超时时间。只在两个连续的写操作之间设置超时,而不是整个请求的传输。如果代理服务器在这段时间内没有收到数据,连接将被关闭。

proxy_read_timeout default 60s

Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for
the transmission of the whole response. If the proxied server does not
transmit anything within this time, the connection is closed.
定义从被代理服务器读取响应的超时。超时设置仅在两个连续的读取操作之间,而不是整个响应的传输。如果代理服务器在这段时间内没有传输数据,连接将被关闭。
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

larance

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值