简体   繁体   English

Nginx / PHP-FPM 504网关超时

[英]Nginx / PHP-FPM 504 Gateway Timeout

I am using php-fpm with nginx. 我正在使用php-fpm和nginx。 I have scripts which take an uploaded excel sheet and process it. 我有脚本,它采取上传的excel表并处理它。 This is a long running job. 这是一项长期工作。 However, after 60 seconds of execution time I get a 504 Gateway Timeout error. 但是,在执行60秒后,我得到504网关超时错误。

The php script keeps running to completion. php脚本一直运行完成。 So nothing is stopping the script from completing. 所以没有什么能阻止脚本完成。

I need to stop this error. 我需要阻止这个错误。

I have been playing with the fastcgi_read_timeout parameter. 我一直在玩fastcgi_read_timeout参数。 However it doesn't seem to fix this problem. 但它似乎没有解决这个问题。 However I know it's taking this parameter into consideration because if I change it to 0 and restart nginx, then the 504 gateway timeout shows straight away. 但是我知道它正在考虑这个参数,因为如果我将它更改为0并重新启动nginx,那么504网关超时会立即显示出来。

location ~ \.php$ {
      try_files $uri =404;
      include /etc/nginx/fastcgi_params;
      fastcgi_pass unix:/var/run/php-fpm/www.sock;
      fastcgi_read_timeout 300;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param PHP_VALUE "upload_max_filesize = 190M \n post_max_size=190M \n max_execution_time = 300";
   }

Any help would be appreciated as I have hit a roadblock in terms of resolving this issue. 任何帮助将不胜感激,因为我在解决这个问题方面遇到了障碍。

I almost completely gave up on this! 我差点完全放弃了! However at the last minute I came up with the answer. 然而在最后一刻我想出了答案。

The servers are on Amazon AWS behind a load balancer. 服务器位于负载均衡器后面的Amazon AWS上。 The load balancer had the idle-timeout attribute set at 60 seconds. 负载均衡器将idle-timeout属性设置为60秒。 Changing this setting fixed the problem!! 更改此设置可解决问题!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM