apache + proxy_fcgi_module + php-fpm: 大 POST 有效负载为空

apache + proxy_fcgi_module + php-fpm: Large POST Payload empty

我在我的网络服务器上将 apache 2.4.10 与 proxy_fcgi 结合使用 php-fpm (7.0.29)。

<IfModule proxy_fcgi_module>
  <FilesMatch ".+\.ph(p[3457]?|t|tml)$">
    SetHandler "proxy:unix:/var/www/xxx/php/php7.0-fpm.sock|fcgi://localhost"
  </FilesMatch>
</IfModule>

当我发送 POST 具有较大负载(> 1MB)的请求时,我在 Apache 的错误日志中收到以下行

[Fri Apr 06 15:33:51 2018] [proxy_fcgi:error] [pid 24162:tid (32)Broken pipe: [client 84.63.x.x:37536] AH01075: Error dispatching request to : (sending stdin), referer: -, request: /index.php, querystring: -

在我的 PHP 代码中,当我从标准输入读取它时,我得到了一个空的负载:

$payload =file_get_contents('php://input');

一切都适用于较小的负载。任何想法出了什么问题?我找不到 proxy_fcgi...

的任何限制设置

感谢您的帮助!

我现在发现问题出在没有发送 Content-Length Header 的分块传输(Transfer-Encoding:分块)上。 mod_proxy_fcgi 似乎不支持正确。

所以唯一可能的解决方案似乎是使用 mod_php,它直接在 apache 进程中运行,而不是通过 FastCGI 或切换到 NginX...

阅读这篇文章了解更多信息:https://www.jeffgeerling.com/blog/2017/apache-fastcgi-proxyfcgi-and-empty-post-bodies-chunked-transfer

另一种解决方法似乎是强制使用不支持分块传输的协议 HTTP/1.0,强制客户端在一个请求中发送全部数据。但这 - 在我的情况下 - 打破了我的 git 客户端中的 TLS 握手。

因为我正在使用我的 PHP 脚本代理到 Git 服务器,我的解决方案是提高 git 客户端的 http 缓冲区,直到我能够切换到NginX.

git config http.postBuffer 524288000