Removing http2 from nginx's listen line turns HTTP/2 off
when I added Nujoom’s HTTPS server block to my nginx config, nginx warned that the listen line was deprecated. on a current nginx (1.27 here) the check prints:
$ nginx -t
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/conf.d/default.conf:2
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
my notes from that day list it under issues fixed:
listen 443 ssl http2; # before
listen 443 ssl; # after
that does make the warning go away, because it removes HTTP/2 from the block. the warning says to use the http2 directive instead, not to drop it:
listen 443 ssl;
http2 on;
nginx -t is clean with that, and the block still speaks HTTP/2. 17 days later I added http2 on; to the portfolio’s server blocks on that server. the Nujoom block isn’t in that commit.
which version
the http2 directive arrived in nginx 1.25.1. on 1.25.0 the replacement is an error, so check nginx -v before swapping:
nginx: [emerg] unknown directive "http2" in /etc/nginx/conf.d/default.conf:3
on 1.25.0, listen 443 ssl http2; still passes nginx -t with no warning, so there’s nothing to fix there.
see also: nothing crashed, sed -i on a bind mount