feat: add setup check for request buffering on FPM#54912
Open
feat: add setup check for request buffering on FPM#54912
Conversation
Context: Using `Transfer-Encoding: chunked` of HTTP 1.1 PHP-FPM has a bug[1] where the request body is not passed to PHP if the `Content-Length` header is missing, while FastCGI in general allows this (I could reproduce that FastCGI passed the request stream from NGinx) PHP-FPM does not forward this to the PHP application. This means when using PHP-FPM we get an empty request body and thus every `PUT` will be an empty file. I tested that `mod_php` is not affected, while it also has no `Content-Length` header, it correctly passed the stream and thus also works without buffering the request. Only PHP-FPM needs buffering of the request so that a `Content-Length` header can be generated. To enable this on Apache set: `SetEnvIfNoCase Transfer-Encoding "chunked" proxy-sendcl=1` On NGinx: `fastcgi_request_buffering on;`. [1]: php/php-src#9441 ref: #7995 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Contributor
Author
|
/backport to stable32 |
Contributor
Author
|
/backport to stable31 |
come-nc
reviewed
Sep 8, 2025
| $url = $this->urlGenerator->linkToRoute('settings.CheckSetup.checkContentLengthHeader'); | ||
| foreach ($this->runRequest('PUT', $url, ['ignoreSSL' => true, 'options' => $options]) as $response) { | ||
| $contentType = $response->getHeader('Content-Type'); | ||
| if (!str_contains(strtolower($contentType), 'application/json')) { |
Contributor
There was a problem hiding this comment.
I’d like a comment for this one, what does it mean if content type is something else?
Contributor
Author
There was a problem hiding this comment.
Then its not a Nextcloud response - some safe guard for reverse proxys so the following check on the response can be done.
| . $this->l10n->t('Due to a limitation of PHP-FPM chunked requests will not be passed to Nextcloud if the server does not buffer such requests.'), | ||
| ); | ||
| } else { | ||
| // Not using FPM but we are on CLI so we do not know if FPM is used |
Contributor
There was a problem hiding this comment.
The endpoint could return $usingFPM while we’re at it, no?
Merged
This was referenced Jan 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Context: Using
Transfer-Encoding: chunkedof HTTP 1.1PHP-FPM has a bug1 where the request body is not passed to PHP if the
Content-Lengthheader is missing, while FastCGI in general allows this (I could reproduce that FastCGI passed the request stream from NGinx) PHP-FPM does not forward this to the PHP application.This means when using PHP-FPM we get an empty request body and thus every
PUTwill be an empty file.I tested that
mod_phpis not affected, while it also has noContent-Lengthheader, it correctly passed the stream and thus also works without buffering the request.Only PHP-FPM needs buffering of the request so that a
Content-Lengthheader can be generated.To enable this on Apache set:
SetEnvIfNoCase Transfer-Encoding "chunked" proxy-sendcl=1On NGinx:
fastcgi_request_buffering on;.ref: #7995
Checklist