mod_h2 icon indicating copy to clipboard operation
mod_h2 copied to clipboard

Apache 2.4.55, mod_http2 v2.0.11 : Connection not closed anymore, when backend are disconnected

Open EIP-Laurent opened this issue 2 years ago • 0 comments

Hello

Since the apache version 2.4.55

using mod_proxy_fcgi with php-fpm and mod_http2

If I do a curl --http2 https://url/sse.php when the php-fpm is restarted the proxy_fcgi is receiving the connection reset, but the connection to the curl are not closed.

If I use http/1.1, the connection with the curl are correctly closed.

Sample httpd.conf

Listen 443

LoadModule mpm_event_module modules/mod_mpm_event.so

LoadModule http2_module modules/mod_http2.so
Protocols h2 h2c http/1.1

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule ssl_module modules/mod_ssl.so

DirectoryIndex index.php index.html
<FilesMatch \.php$>
#    SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
    SetHandler "proxy:unix:/run/php-fpm-legacy/php-fpm.sock|fcgi://localhost/"
</FilesMatch>
<Proxy "fcgi://localhost" enablereuse=off flushpackets=on timeout=300>
</Proxy>

<VirtualHost *:443>
   DocumentRoot /srv/http
   SSLEngine on
   SSLHonorCipherOrder off
   SSLCertificateFile /data/ssl/host.crt
   SSLCertificateKeyFile /data/ssl/host.key
   SSLOpenSSLConfCmd DHParameters /data1/ssl/dhparams.pem
   SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
</VirtualHost>

Sample sse.php

<?php

ini_set('session.use_cookies',false);
session_cache_limiter(false);
session_start();

header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
header("Access-Control-Allow-Origin: *");

function sendMsg($id, $msg) {
  echo "id: $id" . PHP_EOL;
  echo "data: $msg" . PHP_EOL;
  echo PHP_EOL;
  ob_flush();
  flush();
}

while (1) {
      $serverTime = time();
      sendMsg($serverTime, 'server time: ' . date("h:i:s", time()));
      sleep(1);
}

EIP-Laurent avatar Feb 03 '23 09:02 EIP-Laurent