The "listen ... http2" directive is deprecated, use the "http2" directive instead

Issue Summary

  • When installing a new Ghost instance on Ubuntu 24.04 with Nginx version 1.28.0, the following warnings are thrown when running sudo nginx -t to check the NGINX configuration for syntax errors and validity.

    the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/sites-enabled/mywebsite.com-ssl.conf:7

    the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/sites-enabled/mywebsite.com-ssl.conf::8

This is due to the listen … http2 directive being deprecated in NGINX 1.25.1 per this blog article.

  • What did you expect to happen?
    For the install script to not use deprecated syntax when doing the automatic SSL setup and configuration.

Steps to Reproduce

  1. Install Ghost on Ubuntu 24.04 with Nginx version 1.28.0 and then run sudo nginx -t after the installation is complete.

Setup information

Ghost Version
Ghost-CLI version: 1.28.0
Ghost version: 5.130.2

Node.js Version
v22.17.1

How did you install Ghost?
Using the official install guide for Ubuntu except with Ubuntu 24.04 and Nginx version 1.28.0

Provide details of your host & operating system
Oracle Cloud / Ubuntu 24.04.2 LTS / nginx 1.28.0

Database type
MySQL 8

Browser & OS version
N/A

Relevant log / error output
the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/sites-enabled/mywebsite.com-ssl.conf:7

the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/sites-enabled/mywebsite.com-ssl.conf::8

Anyway the fix is easy for anybody wanting to manually correct it.

In /etc/nginx/sites-available/yourwebsite.com-ssl.conf, change

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

to

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    http2 on;

then run sudo nginx -t to verify, then sudo systemctl reload nginx to apply the change.

Sorry, this should probably be moved to Developer Help > Self-Hosting.

The official installation guide only lists Ubuntu 20.04 or 22.04, neither of which include an Nginx version where the above syntax is deprecated. 24.04 doesn’t either, I just updated Nginx myself. :sweat_smile:

Yeah this one’s tricky. I’d be happy to update the CLI with the new http2 directive, but it looks like that individual http2 directive was added at the same time as the listen … http2; directive was deprecated. We’ll probably have to wait until nginx 1.25.1 is a bit more widely available before updating :thinking:

1 Like

No worries, I realized this shouldn’t be in bug reports after I posted. :sweat_smile:

I updated NGINX on my server to the latest 1.28 which is why I was seeing the deprecated syntax warning.

Ubuntu 24.04 doesn’t even come with NGINX 1.25.1 packaged where the syntax was deprecated (it’s still using 1.24.0), so I doubt many will see this deprecated warning anytime soon.

Anyway the fix is in The "listen ... http2" directive is deprecated, use the "http2" directive instead - #2 by ghostdan for anybody whose updated NGINX on their server to 1.25.1 or above.

If you want move this over to the Developer Help > Self-Hosting forum it’s probably more relevant there. :grinning_face_with_smiling_eyes: