Skip to content

JsSse in PHP-FPM setup requires special configuration #2178

@mkrecek234

Description

@mkrecek234

Situation:

  • You are using JsSse to send server-side updates to clients
  • You. are having an environment with Apache and PHP-FPM, buffering pages
  • The default in PHP-FPM under Apache is output buffering which destroys the possibility to use Sse, as the request will only be sent out to client if complete (or buffer size of typically 4096 is reached)

Solution:

  • Configure PHP-FPM in Apache module to allow flush by this configuration in php-fpm.conf for example:
    <FilesMatch ".+\.ph(?:ar|p|tml)$">
        SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
    </FilesMatch>

    <Proxy "fcgi://localhost">
        ProxySet flushpackets=on
        ProxySet flushwait=20
        ProxySet max=10
        ProxySet timeout=100
    </Proxy>

Suggestions to limit flushing packets only on selected scripts or directories are welcome. This way you can keep output buffering for scripts that are non-Sse.

Also see:
php/php-src#12785 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions