【问题标题】:apache proxy_fcgi - The timeout specified has expired - Error dispatching requestapache proxy_fcgi - 指定的超时已过期 - 发送请求时出错
【发布时间】:2018-03-17 14:38:56
【问题描述】:

我有一个 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/JS代码示例?
  • 您使用的是哪个版本的php?您是否尝试过将apache.conf 设置TimeOutProxyTimeout 增加到比他们已有的更大的值?
  • 超时无关紧要,因为它在几次后起作用。后来我再也没有收到这个警告,直到突然发生

标签: php apache webserver apache2


【解决方案1】:

将以下行添加到httpd.confapache2.conf(取决于您的系统)文件中:

Timeout 600
ProxyTimeout 600

然后重启 apache

sudo /etc/init.d/apache2 restart

【讨论】:

  • 不是因为超时。当服务器非常繁忙时似乎会发生这种情况。因为脚本在几秒钟/几分钟后执行良好?
  • 好吧,如果服务器很忙,那么很可能是由于超时
  • 没有为我解决。在 ubuntu 上使用 apache 2.4。
【解决方案2】:

您可以将timeout= 添加到ProxyPassMatch

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

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

【讨论】:

    【解决方案3】:

    我知道这个问题很老了,但是我在删除多个帖子时遇到了 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

    【讨论】:

    • 复制粘贴前请注意错字。 “imeout”应该是“超时”。
    【解决方案4】:

    这可能对其他人有帮助。

    如果您使用的是 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>
    

    【讨论】:

      【解决方案5】:

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

      我可以肯定地说你的代码卡在某个循环中尝试使用 CLI 版本的 PHP 肯定会有所帮助。

      【讨论】:

        【解决方案6】:
        <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 上的默认值 - 在我的情况下,我只需要修改这些值以增加假定的超时时间。

        【讨论】:

          【解决方案7】:

          我终于解决了这个问题。

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

          【讨论】:

            猜你喜欢
            • 2016-01-27
            • 2013-03-08
            • 2017-10-25
            • 2012-04-28
            • 2018-09-09
            • 2021-05-24
            • 2019-02-28
            • 2018-04-06
            • 1970-01-01
            相关资源
            最近更新 更多