Deprecated HTTP/2 Directive in Nginx 1.25.1+

This document addresses the compatibility issues that may arise when implementing the HTTP/2 directive in Nginx configurations, particularly when dealing with different versions of Nginx.

Deprecated Method of Implementing HTTP/2

As of Nginx version 1.25.1, and as per their changeset notes, the previous way to enable HTTP/2 via “listen … http2” is now deprecated.

If you’re running Nginx version 1.25.1 or higher, chances are you’ve encountered the following warnings after testing your Nginx configuration:

[warn] 708259#708259: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/sites-enabled/turnipjuice.media:5
[warn] 708259#708259: the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/sites-enabled/turnipjuice.media:6

The warnings occur as a result of these lines:

listen 443 ssl http2;
listen [::]:443 ssl http2;

More specifically, due to the http2 parameter in them.

New Method of Implementing HTTP/2

As previously mentioned, Nginx version 1.25.1 and higher, introduces some changes to the implementation of HTTP/2 in the Nginx configuration. According to their changeset, the new approach allows sharing HTTP/2 and HTTP/0.9-1.1 on the same port.

Their new implementation, requires the following lines to be changed from:

listen 443 ssl http2;
listen [::]:443 ssl http2;

To:

listen 443 ssl;
listen [::]:443 ssl;
http2 on;

Once the configuration has been changed, the warnings should disappear.

Handling the deprecated HTTP/2 directive on SpinupWP servers

We recommend you to continue using the deprecated directive and avoid the new implementation of the HTTP/2 directive for now. Although this may trigger an Nginx warning, it prevents potential downtime issues.

For instance, if the new implementation of the HTTP/2 directive is used and a site is cloned to a server with an older version of Nginx, the server will fail to recognize the new directive, causing all sites on that server to go down.

We recognize this is not ideal, but using the old implementation and ignoring the warning is currently the safest option to maintain compatibility between SpinupWP servers.

We plan to update our tools to automatically change the HTTP/2 directive to the correct one depending on the Nginx version, but we haven’t done so yet.