【发布时间】:2019-10-22 13:51:20
【问题描述】:
我将 PHP 和 Apache 与 nginx 一起用于反向代理,全部在 Docker 上,并且我有几个长时间运行的调用在 60 秒后计时,导致 504 网关超时。我知道我的应用程序被成功调用,因为我正在跟踪我的 PHP 应用程序的日志,并且我可以看到它正在积极地写入日志。每次都是 60 秒超时,但我似乎无法弄清楚该设置在哪里。
我尝试了this post 中的建议,但没有任何效果。我已经用一些时间相关的设置更新了我的 php.ini 文件,并且我已经验证了它们是用 phpinfo 设置的
max_input_time = 0
max_execution_time = 500
我还将内存限制增加到 512,但考虑到它每次都会在大约 60 秒内超时,我认为这不是问题。
至于更新 nginx 设置,我最初遵循 this tutorial 调整 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 5000;
client_header_timeout 600;
client_body_timeout 600;
fastcgi_read_timeout 300;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
我确保在更新 nginx.conf 文件后运行nginx -s reload。我不知道还能去哪里看,因为我遇到的一切几乎都是我已经做过的。还有什么可能导致 nginx 在 60 秒后超时?谢谢
这是我的 PHP dockerfile
FROM php:7.2-fpm-alpine3.7
RUN apk update; \
apk upgrade;
RUN docker-php-ext-install pdo_mysql
RUN apk add --no-cache php7-pear php7-dev gcc musl-dev make
RUN pecl install xdebug
RUN pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis
【问题讨论】: