docksal / boilerplate-drupal8

[ARCHIVED] Drupal 8 boilerplate project powered by Docksal
https://docksal.io
68 stars 60 forks source link

disable FastCGI buffering #46

Closed yhesse closed 4 years ago

yhesse commented 4 years ago

Is there a way to disable FastCGI buffering? I would love to test BigPipe on my local environment but I'm not sure how to change this in docksal.

https://www.drupal.org/docs/8/core/modules/big-pipe/bigpipe-environment-requirements

achekulaev commented 4 years ago

Howto https://www.jeffgeerling.com/blog/2016/streaming-php-disabling-output-buffering-php-apache-nginx-and-varnish

How to change php.ini https://docs.docksal.io/service/cli/settings/#configuration

yhesse commented 4 years ago

Hi, thanks for the url but I'm still having questions: How and where do I change these values in docksal: # If using PHP-FPM on TCP port 9000. FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -flush -host 127.0.0.1:9000 -pass-header Authorization

output_buffering = Off (=not working)

achekulaev commented 4 years ago

service-web uses mod_fcgi not mod_fastcgi, correct me if I am wrong @lmakarov

lmakarov commented 4 years ago

The default web service in Docksal is Apache (docksal/service-apache) and uses mod_proxy_fcgi.

According to the BigPipe docs on d.o and depending on the Apache version, you may (for Apache >= 2.4.31) or may not (for Apache < 2.4.31) need to apply extra settings there.

The latest Apache version in Docksal is 2.4.35. For this version, which means that the extra flushpackets=on must be set. That would go here. Unfortunately there is currently no support to customize this easily, but we can update that line in config or even add the flexibility to customize these settings via ENV variables in the image.

For now, use the web config override for the default vhost in Apache like this:

In .docksal/etc/apache/httpd-vhost-overrides.conf:

# Additional proxy settings
<Proxy "fcgi://${APACHE_FCGI_HOST_PORT}">
    ProxySet connectiontimeout=5 timeout=600 flushpackets=on
</Proxy>

Note: PHP also has output buffering enabled by default (output_buffering=4096). If your responses fall below 4k in size, then lowering this value or disabling it entirely may be necessary. See docs on how PHP settings can be adjusted in Docksal.

To disable output_buffering in PHP:

In .docksal/etc/php/php-fpm.conf

; PHP FPM settings
[www]
; Maximum amount of memory a script may consume
php_value[output_buffering] = 0

After making these changes, run fin project restart. You should see the following output in web/cli logs respectively:

$ fin logs web
...
web_1       | Configuring Apache2 environment variables...
web_1       | Including configuration overrides from /var/www/.docksal/etc/apache/httpd-vhost-overrides.conf
...

$ fin logs cli
...
cli_1       | 2020-01-28 18:40:21 | Found project level overrides for PHP-FPM. Including:
cli_1       | 2020-01-28 18:40:21 | /var/www/.docksal/etc/php/php-fpm.conf
...

Please test these settings and report back.