apache proxy_fcgi - 指定的超时已过期 - 调度请求时出错

问题描述 投票:0回答:8

我有一个 PHP 应用程序,它返回我:

[Thu Oct 05 22:10:59.351244 2017] [proxy_fcgi:error] [pid 3733:tid 139869435164416] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:46777] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:16:27.701213 2017] [proxy_fcgi:error] [pid 3732:tid 139869359630080] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:46988] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:21:52.971235 2017] [proxy_fcgi:error] [pid 3733:tid 139869426771712] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47055] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:25:23.561216 2017] [proxy_fcgi:error] [pid 3732:tid 139869351237376] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47115] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:30:47.591237 2017] [proxy_fcgi:error] [pid 3733:tid 139869418379008] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47321] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:39:10.211214 2017] [proxy_fcgi:error] [pid 3733:tid 139869443557120] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47407] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:39:38.591259 2017] [proxy_fcgi:error] [pid 3733:tid 139869376415488] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47412] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:45:13.951238 2017] [proxy_fcgi:error] [pid 3733:tid 139869582505728] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47615] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:50:36.491214 2017] [proxy_fcgi:error] [pid 3732:tid 139869460342528] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47668] AH01075: Error dispatching request to : (polling)
[Thu Oct 05 22:54:57.661219 2017] [proxy_fcgi:error] [pid 3733:tid 139869326059264] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47726] AH01075: Error dispatching request to : (polling)

我认为上述消息在某种程度上与以下随机错误有关: 请注意,XMLHttpRequests(AJAX 调用)来自同一域,有时无法执行并出现上述错误。但是,通常他们会执行?

此消息来自哪个脚本?我该如何修复它?我能想到的只有一个脚本可能会超过默认的最大执行时间,但是该脚本允许运行更长时间,使用页面顶部的 ini_set 来获取最大执行时间?

我不知道去哪里寻找以及如何解决这个问题

php apache webserver apache2
8个回答
31
投票

将以下行添加到

httpd.conf
apache2.conf
(取决于您的系统)文件中:

Timeout 600
ProxyTimeout 600

并重新启动apache

sudo /etc/init.d/apache2 restart

9
投票

我知道这个问题已经很老了,但我在删除多个帖子时遇到了 WordPress 的问题,我发现很难找到解决方案,所以我(将来)为我写下这个问题,就像其他有相同问题的人一样问题。

对于 CentOS 8,确保您已安装 fast cgi 和可选的 php-fph

yum install mod_fcgid php-fpm

然后如果没有 php-fpm 编辑:

vi  /etc/httpd/conf.d/fcgid.conf

添加行

FcgidIdleTimeout 1200
FcgidProcessLifeTime 1200
FcgidConnectTimeout 1200
FcgidIOTimeout 1200

如果安装了 php-fpm 编辑/创建:

vi /etc/httpd/conf.modules.d/00-proxy_timeout.conf

并添加行

Timeout 1200
ProxyTimeout 1200

重新启动 php-fpm - 如果已安装和 httpd


2
投票

您可以将

timeout=
添加到
ProxyPassMatch
中。

ProxyPassMatch ^/(.+\.php.*)$ fcgi://127.0.0.1:9000/<docroot>/$1 timeout=1800

看看这里。希望这会有所帮助。


2
投票

这可能对其他人有帮助。

如果您使用的是 Centos 8,我发现以下内容可以解决问题 - 在您的 php.conf 中调用 SetHandler 的位置附近,添加以下内容:

<IfModule !mod_php5.c>
  <IfModule !mod_php7.c>
    # Enable http authorization headers
    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1

    <FilesMatch \.(php|phar)$>
        SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
    </FilesMatch>
  </IfModule>
</IfModule>

<Proxy "unix:/run/php-fpm/www.sock|fcgi://localhost">
    ProxySet connectiontimeout=600 TimeOut=600
</Proxy>

1
投票

我不确定该错误,但很可能您的 PHP 代码应用程序花费的时间比配置的时间长得多。我建议使用 PHP 的 CLI 版本来解决此问题。

我可以肯定地说你的代码陷入了某个循环,尝试使用 PHP 的 CLI 版本,它肯定会有所帮助。


0
投票
<IfModule reqtimeout_module>

    # mod_reqtimeout limits the time waiting on the client to prevent an
    # attacker from causing a denial of service by opening many connections
    # but not sending requests. This file tries to give a sensible default
    # configuration, but it may be necessary to tune the timeout values to
    # the actual situation. Note that it is also possible to configure
    # mod_reqtimeout per virtual host.


    # Wait max 20 seconds for the first byte of the request line+headers
    # From then, require a minimum data rate of 500 bytes/s, but don't
    # wait longer than 40 seconds in total.
    # Note: Lower timeouts may make sense on non-ssl virtual hosts but can
    # cause problem with ssl enabled virtual hosts: This timeout includes
    # the time a browser may need to fetch the CRL for the certificate. If
    # the CRL server is not reachable, it may take more than 10 seconds
    # until the browser gives up.
    RequestReadTimeout header=20-40,minrate=500

    # Wait max 10 seconds for the first byte of the request body (if any)
    # From then, require a minimum data rate of 500 bytes/s
    RequestReadTimeout body=10,minrate=500

</IfModule>

以上似乎是 Debian 上的默认设置 - 在我的例子中,我只需修改这些值以增加假定的超时。


0
投票

终于解决了这个问题。

增加 ProxyTimeout 后,我开始收到此错误。就我而言,问题出在 WAF(Web 应用程序防火墙)配置中。查看access.log(或your_virtual_host.access.log)内部,我意识到所有源IP都是伪装成防火墙IP的,而不是来自互联网的真实IP源。更改此配置 Apache 日志开始了解真实源 IP,问题得到解决。


0
投票

我正在使用 apache2 并看到超时为 0,因此更改为 300 根据建议和我们的要求。
超时 300

但这不可用。 代理超时 600

© www.soinside.com 2019 - 2024. All rights reserved.