我使用 PHP 和 Apache 以及 nginx 进行反向代理,全部都在 Docker 上,并且我有几个长时间运行的调用,这些调用在 60 秒后计时,导致 504 网关超时。我知道我的应用程序被成功调用,因为我正在跟踪 PHP 应用程序的日志,并且我可以看到它正在积极写入日志。每次都是 60 秒超时,但我似乎无法弄清楚该设置在哪里。
我尝试了这篇文章中的建议,但没有任何效果。我已经用一些与时间相关的设置更新了我的 php.ini 文件,并且我已经验证它们是使用 phpinfo 设置的
max_input_time = 0
max_execution_time = 500
Run Code Online (Sandbox Code Playgroud)
我还将内存限制增加到 512,但考虑到每次都会在大约 60 秒内超时,我认为这不是问题。
至于更新 nginx 设置,我最初按照本教程调整 nginx-proxy 超时,但这不起作用。我取消了更改,然后 ssh 进入容器并手动更新 /etc/nginx/nginx.conf,http 部分如下所示
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 500;
proxy_connect_timeout 600;
proxy_send_timeout 600;
send_timeout 600;
client_max_body_size …Run Code Online (Sandbox Code Playgroud)