ddev / ddev

Docker-based local PHP+Node.js web development environments
https://ddev.com
Apache License 2.0
2.69k stars 595 forks source link

Configure nginx with PHP to pass X-Accel-* headers to client #6563

Open andriokha opened 1 week ago

andriokha commented 1 week ago

Is there an existing issue for this?

Is your feature request related to a problem?

I tried to run the Drupal functional test \Drupal\Tests\big_pipe\Functional\BigPipeTest and got some errors

Details ``` PHPUnit 9.6.20 by Sebastian Bergmann and contributors. Testing Drupal\Tests\big_pipe\Functional\BigPipeTest .EE. 4 / 4 (100%) Time: 00:14.646, Memory: 6.00 MB There were 2 errors: 1) Drupal\Tests\big_pipe\Functional\BigPipeTest::testBigPipe Behat\Mink\Exception\ExpectationException: Current response header "X-Accel-Buffering" is "", but "no" expected. /var/www/html/vendor/behat/mink/src/WebAssert.php:888 /var/www/html/vendor/behat/mink/src/WebAssert.php:180 /var/www/html/web/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php:338 /var/www/html/web/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php:161 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:729 2) Drupal\Tests\big_pipe\Functional\BigPipeTest::testBigPipeNoJs Behat\Mink\Exception\ExpectationException: Current response header "X-Accel-Buffering" is "", but "no" expected. /var/www/html/vendor/behat/mink/src/WebAssert.php:888 /var/www/html/vendor/behat/mink/src/WebAssert.php:180 /var/www/html/web/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php:338 /var/www/html/web/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php:251 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:729 ERRORS! Tests: 4, Assertions: 86, Errors: 2. ```

It looks like the bigpipe test is trying to verify the X-Accel-Buffering header is correctly set, while nginx by default filters it out.

Describe your solution

You can use the following config to make nginx forward the header:

fastcgi_pass_header "X-Accel-Buffering";

There are other X-Accel-* headers too that might be useful during development that can be forwarded:

Describe alternatives

No response

Additional context

I've fixed it locally by customizing the nginx config, but I thought it might be useful to make it the default, either for Drupal or more generally, if DDEV is aimed primarily at development. Thanks!

rfay commented 1 week ago

Have you already tried it by adding your own .ddev/nginx_full/nginx_site.conf?

Do you think this is a correct thing to do for everybody? If so, after you have tested it, please add a PR.

andriokha commented 1 week ago

Thanks @rfay

Have you already tried it by adding your own .ddev/nginx_full/nginx_site.conf?

Yup

Do you think this is a correct thing to do for everybody?

I can't think of any negatives. I guess it's normally not forwarded because it's considered an internal directive and it's generally better not to be promiscuous. But I'm not a sysad (:

I've made #6564 where I was bold and decided to forward all the X-Accel-* headers, as it feels like the others could be useful for the same reason, but happy to cut it back if desired.

andriokha commented 1 week ago

Updated issue description to be about passing all X-Accel-* headers.