Description
I am using the Heroku PHP Buildpack with Router 2.0 enabled, which supports HTTP/2 between the client and the router. However, the communication between the Heroku Router and the Dyno still uses HTTP/1.1 because the NGINX configuration in the buildpack does not enable HTTP/2 (h2c). This limits the performance benefits of HTTP/2, especially for parallel requests.
Problem
The current NGINX configuration (conf/nginx/heroku.conf.php) does not enable HTTP/2 for the connection between the Router and the Dyno. Since Heroku terminates TLS at the Router, the Dyno must support HTTP/2 without TLS (h2c). NGINX (version 1.26.3 in the buildpack) supports h2c, but it needs to be explicitly enabled in the configuration.
Proposed Solution
I suggest adding HTTP/2 support by modifying the listen directive in the server block of the NGINX configuration. The change is minimal:
Current:
nginx
listen <?=getenv('PORT')?:'8080'?>;
Proposed:
nginx
listen <?=getenv('PORT')?:'8080'?>;
<?php if (getenv('HEROKU_PHP_NGINX_HTTP2')) { ?>
http2 on;
<?php } ?>
To make this optional and backward-compatible, you could introduce an environment variable (e.g., HEROKU_PHP_NGINX_HTTP2) to control whether HTTP/2 is enabled:
heroku config:set HEROKU_PHP_NGINX_HTTP2=1
Benefits
Improved performance for parallel requests due to HTTP/2 multiplexing between Router and Dyno.
Better utilization of Router 2.0's HTTP/2 capabilities.
Minimal change with optional activation to avoid breaking existing setups.