Apache proxfy_fcgi - 发送请求时出错

Posted

技术标签:

【中文标题】Apache proxfy_fcgi - 发送请求时出错【英文标题】:Apache proxfy_fcgi - Error dispatching request to 【发布时间】:2016-01-27 07:51:45 【问题描述】:

我在 Google 上有云托管,老实说这很糟糕,但我正在尝试继续使用它,我在 VM 上安装了 LAMP 堆栈并将我的网站放在 htdocs 中。当我尝试访问我的网站时,它会给我request timeout,但有时它会工作 5 分钟左右。

当我看到 apache 错误日志时,它给了我这个

075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:55.185819 2015] [proxy_fcgi:error] [pid 4995:tid 140183521683200] (70007)The timeout specified has expired: [client 162.158.255.169:34198] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:55.487458 2015] [core:notice] [pid 2953:tid 140183785137920] AH00052: child pid 4995 exit signal Segmentation fault (11)
[Tue Oct 27 18:12:55.787973 2015] [proxy_fcgi:error] [pid 5063:tid 140183530075904] (70007)The timeout specified has expired: [client 199.27.133.137:13151] AH01075: Error dispatching request to : (polling), referer: http://whichtube.com/watch/g9-4dCeFQng/allama-nasir-abbas-jawab-ali-as-nae-talwar-kayou-na-uthai.html
[Tue Oct 27 18:12:57.542883 2015] [proxy_fcgi:error] [pid 5329:tid 140183521683200] (70007)The timeout specified has expired: [client 173.245.56.198:51348] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:57.976752 2015] [proxy_fcgi:error] [pid 5063:tid 140183479719680] (70007)The timeout specified has expired: [client 173.245.56.198:63779] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:58.993666 2015] [proxy_fcgi:error] [pid 5194:tid 140183496505088] (70007)The timeout specified has expired: [client 162.158.255.141:16226] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:59.196701 2015] [proxy_fcgi:error] [pid 5329:tid 140183513290496] (70007)The timeout specified has expired: [client 173.245.56.198:32819] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:01.462039 2015] [proxy_fcgi:error] [pid 5329:tid 140183504897792] (70007)The timeout specified has expired: [client 199.27.128.166:48057] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:07.518999 2015] [proxy_fcgi:error] [pid 5063:tid 140183471326976] (70007)The timeout specified has expired: [client 173.245.56.198:13694] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:16.804990 2015] [proxy_fcgi:error] [pid 5261:tid 140183513290496] (70007)The timeout specified has expired: [client 199.27.128.134:28694] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:33.055860 2015] [proxy_fcgi:error] [pid 5328:tid 140183236331264] (70007)The timeout specified has expired: [client 39.41.139.220:52154] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:57.391361 2015] [proxy_fcgi:error] [pid 5063:tid 140183521683200] (70007)The timeout specified has expired: [client 39.41.139.220:52029] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:57.552542 2015] [core:notice] [pid 2953:tid 140183785137920] AH00052: child pid 5063 exit signal Segmentation fault (11)

我的网站是用 php 编写的,除了目录权限外,我没有更改任何其他内容,有什么我遗漏的吗?

【问题讨论】:

【参考方案1】:

我遇到了同样的问题,原来 Apache 有处理超时的模块,称为 mod_reqtimeout

默认值(你不会在默认的http.conf中看到)是:

RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500

在我的情况下,我通过纯 HTML 表单提交上传文件,因此该文件在技术上是标题的一部分,默认配置表示标题将在 20 到 40 秒时超时。 20-40 的东西很酷,因为它会在 20 秒时超时,但是如果在一秒钟内发送 500 个字节,它将增加一秒的等待时间,直到达到 40 秒,然后无论如何都会超时。

我在我的网站上上传了较大的文件,所以我将这一行添加到我的 httpd.conf 文件中:

RequestReadTimeout handshake=0 header=20-600,MinRate=500 body=20,MinRate=500

只要我的用户以至少 500 字节/秒的速度发送数据,请求就不会超时,直到最大值。达到 600 秒(最好阅读文档,不要引用我的吞吐率)

它实际上是一个非常酷的 Apache 模块,但并不是众所周知的,因为人们建议在其他类似的“指定的超时已过期:”中更改其他 apache 超时设置与 PHP-FPM 相关的问题,但是这个问题发生在任何需要的帖子中超过 40 秒在 Apache 中默认提交。

【讨论】:

proxy_fcgi 的 AH01075 错误消息是说代理到 php-fpm 的请求已超时,可能是因为已超出 ProxyTimeout。你是说当RequestReadTimeout 被触发时你会看到同样的错误?我问是因为如果涉及RequestReadTimeout,我希望看到类似 "Request body read timeout" 的内容。 @molecularbear 我得到的确切错误是:[Fri May 10 13:19:41.073170 2019] [proxy_fcgi:error] [pid 26964:tid 140276668856064] (70007)The timeout specified has expired: [client 201.17.156.113:2022] AH01075: Error dispatching request to : (reading input brigade), referer: https://siste.. 此超时是因为用户上传到我的 php 脚本的文件(实际上是在 POST 标头中发送的)花费的时间比默认值长值所以它超时了。【参考方案2】:

您的 PHP 代码完成的时间似乎比配置的超时时间长。当 apache 使用 fcgi 加载 PHP 页面时,它会将请求发送到 PHP-FPM 服务以进行处理。如果 PHP-FPM 响应时间过长,您将看到这种类型的超时。可能的原因是;您的 PHP 代码可能会卡在一个循环中,或者等待来自数据库的响应需要很长时间。

为了解决问题,我会使用 php 的 CLI 版本来查看脚本是否在合理的时间内完成($ time php /path/to/file.php)。 PHP-FPM 日志中可能有其他信息(默认:/var/log/php-fpm.log)。

【讨论】:

【参考方案3】:

对我来说,重新启动 php-fpm 完成了这项工作。按照@varlogtim 的建议查看日志后。日志显示过去 12 小时内没有任何活动...

【讨论】:

【参考方案4】:

我也有这个问题。您可能希望在代码中查找硬代码部分以及与另一个不可用服务器的连接。 (例如无法在线访问的本地 IP)。

对于我来说,我检查了服务器上的 php-fpm.log,发现我的应用程序正在尝试连接到旧服务器(错误的 IP)并且它面临超时。

【讨论】:

【参考方案5】:

我遇到了同样的问题,在我的情况下,这个解决方案有效:

增加位于我的request_terminate_timeout/etc/php-fpm.d/www.conf 文件。

注意:此选项会覆盖 php max_execution_time ini 选项并为其设置较低的值可能会给您带来很多麻烦,因为它会覆盖其他选项并强行杀死请求超时是否过期。 (如果您询问要设置哪个值;它应该是根据您的需要的最大脚本处理时间,但通常 600 秒(10 分钟)或 10 米(10 分钟)已经足够了。)

【讨论】:

【参考方案6】:

我在 Centos 7 上遇到了同样的问题:SELINUX 的问题。 您可以暂时禁用 SELINUX 以检查: sudo setenforce 0

【讨论】:

以上是关于Apache proxfy_fcgi - 发送请求时出错的主要内容,如果未能解决你的问题,请参考以下文章

httpclient如何发送get请求

Apache + mod_wsgi + django:为积压的请求发送默认响应

如何接收httpclient发送的请求

通过 Apache Commons HttpClient 发送 HTTPS 请求

Java 发送 post请求

Java 发送 post请求