ServerHandbook live check: run log ------------------------------------------------------------------------------ Check scripts/live/checks/nginx-http2-ubuntu.mjs (sha256 5c4056354f65dc21e76e58099d4458c21fd3c7d81e5c2c57b9ab8f36d994c985) Ran at 2026-11-18T09:22:57Z (418 s) Result PASS, all 26 claims held Tested on System Ubuntu 24.04.4 LTS Kernel 6.8.0-138-generic Package nginx 1.24.0-2ubuntu7.19 Package openssl 3.0.13-0ubuntu3.15 Package certbot 2.9.0-1 Package python3-certbot-nginx 2.9.0-1 Package curl 8.5.0-2ubuntu10.13 Setup A fresh Ubuntu 24.04 cloud server from a hosting provider (its stock image, a public IPv4 address), with a domain and its www name pointed at it, ufw on, Nginx serving one site with a Let’s Encrypt certificate for both names and the www and HTTPS redirects, as the earlier articles leave it; reached over SSH as a sudo user. HTTP/2 was also checked from another network. Every version above was read from the server at run time. Passwords used on the throwaway test server are shown as [password]. How we test: https://serverhandbook.com/how-we-test ------------------------------------------------------------------------------ What the steps changed on the server (recorded before the first step and after the last) Packages added (0) Packages upgraded (0) Packages removed (0) Services enabled at boot (0) Services disabled (0) Listening sockets opened (0) Listening sockets closed (0) Files added in /etc (3) /etc/letsencrypt/accounts/acme-staging-v02.api.letsencrypt.org/directory/dc21971eb0bc44f30448b915e3094b93/meta.json /etc/letsencrypt/accounts/acme-staging-v02.api.letsencrypt.org/directory/dc21971eb0bc44f30448b915e3094b93/private_key.json /etc/letsencrypt/accounts/acme-staging-v02.api.letsencrypt.org/directory/dc21971eb0bc44f30448b915e3094b93/regr.json Files changed in /etc (1) /etc/nginx/sites-available/example.com Files removed from /etc (0) Disk used on / (includes logs written during the run): +0.2 MB ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Audit: testssl ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Claims (26), each with what the run saw ------------------------------------------------------------------------------ 1. ok a bare Ubuntu 24.04 server box (web-server) starts 2. ok (setup) certbot got a certificate for example.com and www.example.com | Saving debug log to /var/log/letsencrypt/letsencrypt.log | Account registered. | Requesting a certificate for example.com and www.example.com | | Successfully received certificate. | Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem | Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem | This certificate expires on 2027-02-16. | These files will be updated when the certificate renews. | Certbot has set up a scheduled task to automatically renew this certificate in the background. | | Deploying certificate | Successfully deployed certificate for example.com to /etc/nginx/sites-enabled/example.com | Successfully deployed certificate for www.example.com to /etc/nginx/sites-enabled/example.com | Congratulations! You have successfully enabled HTTPS on https://example.com and https://www.example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | If you like Certbot, please consider supporting our work by: | * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate | * Donating to EFF: https://eff.org/donate-le | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3. ok before: curl talks HTTP/1.1 to https://example.com (curl offers h2; the server does not) | 1.1 4. ok Ubuntu’s nginx is built with http_v2_module and without http_v3_module | http_v2_module 5. ok nginx -v: nginx/1.24.0 (Ubuntu) | nginx version: nginx/1.24.0 (Ubuntu) 6. ok the file has four `listen … 443 ssl;` lines (two HTTPS blocks, IPv4 + IPv6) | 3: listen 80; | 4: listen [::]:80; | 11: listen 443 ssl; | 12: listen [::]:443 ssl; | 23: listen 443 ssl; | 24: listen [::]:443 ssl; 7. ok after sed: all four 443 lines read `443 ssl http2;`, the port-80 lines are unchanged | 3: listen 80; | 4: listen [::]:80; | 11: listen 443 ssl http2; | 12: listen [::]:443 ssl http2; | 23: listen 443 ssl http2; | 24: listen [::]:443 ssl http2; 8. ok nginx -t is successful | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok | nginx: configuration file /etc/nginx/nginx.conf test is successful 9. ok after: curl talks HTTP/2 to https://example.com | 2 10. ok the status line is `HTTP/2 200` | HTTP/2 200 11. ok the www redirect also answers over HTTP/2: `HTTP/2 301` | HTTP/2 301 12. ok openssl: the TLS handshake picks `ALPN protocol: h2` | ALPN protocol: h2 13. ok (from another network) curl gets HTTP/2 200 | 2 200 14. ok plain http stays HTTP/1.1 (the redirect): `HTTP/1.1 301 Moved Permanently` | HTTP/1.1 301 Moved Permanently 15. ok `http2 on;` on nginx 1.24: [emerg] unknown directive "http2", test failed | 2026/11/18 09:26:14 [emerg] 4126#4126: unknown directive "http2" in /etc/nginx/conf.d/http2.conf:1 | nginx: configuration file /etc/nginx/nginx.conf test failed 16. ok (the file removed, nginx -t is successful again) | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok | nginx: configuration file /etc/nginx/nginx.conf test is successful 17. ok http2 in the main block only: nginx -t is successful | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok | nginx: configuration file /etc/nginx/nginx.conf test is successful 18. ok …and the www block, with no http2 on its lines, still answers HTTP/2 (same address and port) | HTTP/2 301 19. ok certbot renew --dry-run succeeds | Saving debug log to /var/log/letsencrypt/letsencrypt.log | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Processing /etc/letsencrypt/renewal/example.com.conf | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Account registered. | Simulating renewal of an existing certificate for example.com and www.example.com | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Congratulations, all simulated renewals succeeded: | /etc/letsencrypt/live/example.com/fullchain.pem (success) | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 20. ok …and the four `ssl http2` lines are still there | 4 21. ok …and the site still answers HTTP/2 | 2 22. ok (the config tests clean at the end of the steps) | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok | nginx: configuration file /etc/nginx/nginx.conf test is successful 23. ok (tested on) the box reports its OS, kernel and the version of 5 package(s) | PRETTY_NAME="Ubuntu 24.04.4 LTS" | VIRT=none | KERNEL=6.8.0-138-generic | PKG certbot 2.9.0-1 | PKG curl 8.5.0-2ubuntu10.13 | PKG nginx 1.24.0-2ubuntu7.19 | PKG openssl 3.0.13-0ubuntu3.15 | PKG python3-certbot-nginx 2.9.0-1 24. ok undo: nginx -t successful | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok | nginx: configuration file /etc/nginx/nginx.conf test is successful 25. ok undo: back to HTTP/1.1 | 1.1 26. ok (cleanup) the certificate the run got is revoked | Saving debug log to /var/log/letsencrypt/letsencrypt.log | Deleted all files relating to certificate example.com. | Congratulations! You have successfully revoked the certificate that was located at /etc/letsencrypt/live/example.com/cert.pem. ------------------------------------------------------------------------------ Commands and what they printed (25) ------------------------------------------------------------------------------ $ curl -sI https://example.com -o /dev/null -w '%{http_version}\n' 1.1 $ nginx -V 2>&1 | grep -oE 'http_v[23]_module' http_v2_module $ nginx -v nginx version: nginx/1.24.0 (Ubuntu) $ grep -n 'listen' /etc/nginx/sites-available/example.com 3: listen 80; 4: listen [::]:80; 11: listen 443 ssl; 12: listen [::]:443 ssl; 23: listen 443 ssl; 24: listen [::]:443 ssl; $ sudo cp /etc/nginx/sites-available/example.com ~/example.com.before-http2 $ sudo sed -i 's/listen \(.*\)443 ssl;/listen \1443 ssl http2;/' /etc/nginx/sites-available/example.com $ grep -n 'listen' /etc/nginx/sites-available/example.com 3: listen 80; 4: listen [::]:80; 11: listen 443 ssl http2; 12: listen [::]:443 ssl http2; 23: listen 443 ssl http2; 24: listen [::]:443 ssl http2; $ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful $ sudo systemctl reload nginx $ curl -sI https://example.com -o /dev/null -w '%{http_version}\n' 2 $ curl -sI https://example.com | head -n 1 HTTP/2 200 $ curl -sI https://www.example.com | head -n 1 HTTP/2 301 $ echo | openssl s_client -connect example.com:443 -servername example.com -alpn h2 2>/dev/null | grep -a ALPN ALPN protocol: h2 $ curl -sI http://example.com | head -n 1 HTTP/1.1 301 Moved Permanently $ echo 'http2 on;' | sudo tee /etc/nginx/conf.d/http2.conf http2 on; $ sudo nginx -t 2026/11/18 09:26:14 [emerg] 4126#4126: unknown directive "http2" in /etc/nginx/conf.d/http2.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed $ sudo rm /etc/nginx/conf.d/http2.conf $ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful $ curl -sI https://www.example.com | head -n 1 HTTP/2 301 $ sudo certbot renew --dry-run Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Processing /etc/letsencrypt/renewal/example.com.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Account registered. Simulating renewal of an existing certificate for example.com and www.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations, all simulated renewals succeeded: /etc/letsencrypt/live/example.com/fullchain.pem (success) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $ grep -c 'ssl http2' /etc/nginx/sites-available/example.com 4 $ curl -sI https://example.com -o /dev/null -w '%{http_version}\n' 2 $ sudo sed -i 's/ ssl http2;/ ssl;/' /etc/nginx/sites-available/example.com $ sudo nginx -t && sudo systemctl reload nginx nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful $ curl -sI https://example.com -o /dev/null -w '%{http_version}\n' 1.1 ------------------------------------------------------------------------------ testssl: its full screen before the first step ------------------------------------------------------------------------------ (not run before the steps: no HTTPS yet) ------------------------------------------------------------------------------ testssl: its full screen after the last step ------------------------------------------------------------------------------ Start 2026-11-18 09:27:41 -->> 203.0.113.10:443 (example.com) <<-- rDNS (203.0.113.10): . Service detected: HTTP Testing protocols via sockets except NPN+ALPN SSLv2 not offered (OK) SSLv3 not offered (OK) TLS 1 not offered TLS 1.1 not offered TLS 1.2 offered (OK) TLS 1.3 offered (OK): final NPN/SPDY not offered ALPN/HTTP2 h2, http/1.1 (offered) Testing cipher categories NULL ciphers (no encryption) not offered (OK) Anonymous NULL Ciphers (no authentication) not offered (OK) Export ciphers (w/o ADH+NULL) not offered (OK) LOW: 64 Bit + DES, RC[2,4], MD5 (w/o export) not offered (OK) Triple DES Ciphers / IDEA not offered Obsoleted CBC ciphers (AES, ARIA etc.) not offered Strong encryption (AEAD ciphers) with no FS not offered Forward Secrecy strong encryption (AEAD ciphers) offered (OK) Testing server's cipher preferences Hexcode Cipher Suite Name (OpenSSL) KeyExch. Encryption Bits Cipher Suite Name (IANA/RFC) ----------------------------------------------------------------------------------------------------------------------------- SSLv2 - SSLv3 - TLSv1 - TLSv1.1 - TLSv1.2 (no server order, thus listed by strength) xc02c ECDHE-ECDSA-AES256-GCM-SHA384 ECDH 521 AESGCM 256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 xcca9 ECDHE-ECDSA-CHACHA20-POLY1305 ECDH 521 ChaCha20 256 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 xc02b ECDHE-ECDSA-AES128-GCM-SHA256 ECDH 521 AESGCM 128 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 TLSv1.3 (no server order, thus listed by strength) x1302 TLS_AES_256_GCM_SHA384 ECDH 253 AESGCM 256 TLS_AES_256_GCM_SHA384 x1303 TLS_CHACHA20_POLY1305_SHA256 ECDH 253 ChaCha20 256 TLS_CHACHA20_POLY1305_SHA256 x1301 TLS_AES_128_GCM_SHA256 ECDH 253 AESGCM 128 TLS_AES_128_GCM_SHA256 Has server cipher order? no (limited sense as client will pick) Testing robust forward secrecy (FS) -- omitting Null Authentication/Encryption, 3DES, RC4 FS is offered (OK) TLS_AES_256_GCM_SHA384 TLS_CHACHA20_POLY1305_SHA256 ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-ECDSA-CHACHA20-POLY1305 TLS_AES_128_GCM_SHA256 ECDHE-ECDSA-AES128-GCM-SHA256 KEMs offered None Elliptic curves offered: prime256v1 secp384r1 secp521r1 X25519 X448 Finite field group: ffdhe2048 ffdhe3072 ffdhe4096 ffdhe6144 ffdhe8192 TLS 1.2 sig_algs offered: ECDSA+SHA512 ECDSA+SHA384 ECDSA+SHA256 ECDSA+SHA224 TLS 1.3 sig_algs offered: ECDSA+SHA256 Testing server defaults (Server Hello) TLS extensions (standard) "server name/#0" "max fragment length/#1" "supported_groups/#10" "EC point formats/#11" "application layer protocol negotiation/#16" "extended master secret/#23" "supported versions/#43" "key share/#51" "renegotiation info/#65281" Session Ticket RFC 5077 hint no -- no lifetime advertised SSL Session ID support yes Session Resumption Tickets no, ID: yes TLS clock skew Random values, no fingerprinting possible Certificate Compression none Client Authentication none Signature Algorithm ECDSA with SHA384 Server key size EC 256 bits (curve P-256) Server key usage Digital Signature Server extended key usage TLS Web Server Authentication Serial 05859E7B7D6777F9AAD4FBAB8340E45DA1EF (OK: length 18) Fingerprints SHA1 1A6796B34EAFF48CA270D0940B611E3B0E34F87C SHA256 93BB26D19C2BEBB63CC123DE7796E729EE45637063EA62140EE120725D58EAD1 Common Name (CN) example.com subjectAltName (SAN) example.com www.example.com Trust (hostname) Ok via SAN and CN (same w/o SNI) Chain of trust Ok EV cert (experimental) no Certificate Validity (UTC) 89 >= 30 days (2026-11-18 08:26 --> 2027-02-16 08:26) ETS/"eTLS", visibility info not present Certificate Revocation List http://ye1.c.lencr.org/112.crl OCSP URI -- OCSP stapling not offered OCSP must staple extension -- DNS CAA RR (experimental) not offered Certificate Transparency yes (certificate extension) Certificates provided 4 Issuer YE1 (Let's Encrypt from US) Intermediate cert validity #1: ok > 40 days (2028-09-02 23:59). YE1 <-- Root YE #2: ok > 40 days (2032-09-02 23:59). Root YE <-- ISRG Root X2 #3: ok > 40 days (2032-09-02 23:59). ISRG Root X2 <-- ISRG Root X1 Intermediate Bad OCSP (exp.) Ok Testing HTTP header response @ "/" HTTP Status Code 200 OK HTTP clock skew 0 sec from localtime Strict Transport Security not offered Public Key Pinning -- Server banner nginx/1.24.0 (Ubuntu) Application banner -- Cookie(s) (none issued at "/") Security headers -- Reverse Proxy banner -- Testing vulnerabilities Heartbleed (CVE-2014-0160) not vulnerable (OK), no heartbeat extension CCS (CVE-2014-0224) not vulnerable (OK) Ticketbleed (CVE-2016-9244), experiment. not vulnerable (OK), no session ticket extension ROBOT Server does not support any cipher suites that use RSA key transport Secure Renegotiation (RFC 5746) supported (OK) Secure Client-Initiated Renegotiation not vulnerable (OK) CRIME, TLS (CVE-2012-4929) not vulnerable (OK) BREACH (CVE-2013-3587) potentially NOT ok, "gzip" HTTP compression detected. - only supplied "/" tested Can be ignored for static pages or if no secrets in the page POODLE, SSL (CVE-2014-3566) not vulnerable (OK), no SSLv3 support TLS_FALLBACK_SCSV (RFC 7507) No fallback possible (OK), no protocol below TLS 1.2 offered SWEET32 (CVE-2016-2183, CVE-2016-6329) not vulnerable (OK) FREAK (CVE-2015-0204) not vulnerable (OK) DROWN (CVE-2016-0800, CVE-2016-0703) not vulnerable on this host and port (OK) no RSA certificate, thus certificate can't be used with SSLv2 elsewhere LOGJAM (CVE-2015-4000), experimental not vulnerable (OK): no DH EXPORT ciphers, no DH key detected with <= TLS 1.2 BEAST (CVE-2011-3389) not vulnerable (OK), no SSL3 or TLS1 LUCKY13 (CVE-2013-0169), experimental not vulnerable (OK) Winshock (CVE-2014-6321), experimental not vulnerable (OK) RC4 (CVE-2013-2566, CVE-2015-2808) no RC4 ciphers detected (OK) Running client simulations (HTTP) via sockets Browser Protocol Cipher Suite Name (OpenSSL) Forward Secrecy ------------------------------------------------------------------------------------------------ Android 7.0 (native) TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256) Android 8.1 (native) TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 253 bit ECDH (X25519) Android 9.0 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Android 10.0 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Android 11/12 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Android 13/14 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Android 15 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Chrome 101 (Win 10) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Chromium 137 (Win 11) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Firefox 100 (Win 10) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Firefox 137 (Win 11) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) IE 8 Win 7 No connection IE 11 Win 7 TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256) IE 11 Win 8.1 TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256) IE 11 Win Phone 8.1 TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256) IE 11 Win 10 TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256) Edge 15 Win 10 TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 253 bit ECDH (X25519) Edge 101 Win 10 21H2 TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Edge 133 Win 11 23H2 TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Safari 18.4 (iOS 18.4) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Safari 15.4 (macOS 12.3.1) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Safari 18.4 (macOS 15.4) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Java 7u25 No connection Java 8u442 (OpenJDK) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519) Java 11.0.2 (OpenJDK) TLSv1.3 TLS_AES_128_GCM_SHA256 256 bit ECDH (P-256) Java 17.0.3 (OpenJDK) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519) Java 21.0.6 (OpenJDK) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519) go 1.17.8 TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) LibreSSL 3.3.6 (macOS) TLSv1.3 TLS_CHACHA20_POLY1305_SHA256 253 bit ECDH (X25519) OpenSSL 1.0.2e TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256) OpenSSL 1.1.1d (Debian) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519) OpenSSL 3.0.15 (Debian) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519) OpenSSL 3.5.0 (git) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519) Apple Mail (16.0) TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256) Thunderbird (91.9) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519) Rating (experimental) Rating specs (not complete) SSL Labs's 'SSL Server Rating Guide' (version 2009r from 2025-05-16) Specification documentation https://github.com/ssllabs/research/wiki/SSL-Server-Rating-Guide Protocol Support (weighted) 100 (30) Key Exchange (weighted) 100 (30) Cipher Strength (weighted) 90 (36) Final Score 96 Overall Grade A+ Done 2026-11-18 09:29:30 [ 114s] -->> 203.0.113.10:443 (example.com) <<-- ------------------------------------------------------------------------------ The check's source (scripts/live/checks/nginx-http2-ubuntu.mjs) As it ran. ------------------------------------------------------------------------------ /** * KB: enable HTTP/2 in Nginx on Ubuntu 26.04 and 24.04 (run per release; proof standard v2 2026-11-18, testssl.sh from * a second server after the steps). On 26.04 (nginx 1.28) the step is `http2 on;` in its own conf.d file, and the old * `listen … http2` form is shown for what it now prints; on 24.04 (nginx 1.24) as below. See which protocol the site speaks now (HTTP/1.1 over HTTPS) and that * Ubuntu's nginx 1.24 has the HTTP/2 module but no HTTP/3; add `http2` to every `listen … 443 ssl` line; nginx -t and * reload; check it with curl (the site and the www redirect), with openssl (ALPN: h2), and from another network; * plain http stays HTTP/1.1; `http2 on;` (the nginx 1.25.1+ form) is an "unknown directive" here; HTTP/2 is per * address and port, so one block with it turns it on for every site on 443; renewal leaves the lines alone; undo. * * Runs ONLY on a real rented server (LIVE_VPS=root@
LIVE_VPS_DOMAIN=, box.mjs `vps`): browsers use * HTTP/2 only over HTTPS with a certificate they trust, from a public certificate authority that reaches port 80. * Commands use example.com; box.mjs swaps the real name in on the way out and back on the way in. * * Hidden setup, as the earlier articles leave the server: the sudo user `deploy`, ufw on with SSH and 'Nginx Full', * Nginx with a site for example.com and www.example.com, a certificate for both names from certbot, and the three * server blocks of the redirect article (port 80 → https://example.com, https://www → https://example.com, the site). * * LIVE_LE_STAGING=1 sends certbot to Let's Encrypt's STAGING server while the check is written (never saved). At the * end (hidden) the certificate is revoked, so none stays valid for a name we do not use. */ import { spawnSync } from 'node:child_process' import { VPS, VPS_DOMAIN } from '../box.mjs' import { bareBox, reportBox } from '../lib.mjs' const STAGING = process.env.LIVE_LE_STAGING === '1' export const meta = { saveRun: !STAGING, audits: ['testssl'] } const RELEASE = process.env.LIVE_BOX_RELEASE || '24.04' const NEW = RELEASE !== '24.04' // nginx 1.25.1+: the http2 directive const le = (cmd) => (STAGING ? cmd.replace(/^sudo certbot (\S+)/, 'sudo certbot $1 --test-cert') : cmd) const K = STAGING ? ' -k' : '' /** From another network (this machine), over the internet: the HTTP version curl used, and the status. */ const fromOutside = (url) => ( spawnSync( 'curl', ['-s', ...(STAGING ? ['-k'] : []), '-o', '/dev/null', '-m', '10', '-w', '%{http_version} %{http_code}', url.split('example.com').join(VPS_DOMAIN)], { encoding: 'utf8' }, ).stdout ?? '' ).trim() const FILE = '/etc/nginx/sites-available/example.com' const SSL = ` ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;` /** The redirect article's three blocks. `h2www` / `h2main`: whether each HTTPS block's listen lines carry http2. */ const blocks = (h2www, h2main) => `# 1. HTTP, both names: go to https://example.com server { listen 80; listen [::]:80; server_name example.com www.example.com; return 301 https://example.com$request_uri; } # 2. HTTPS, www: go to https://example.com server { listen 443 ssl${h2www ? ' http2' : ''}; listen [::]:443 ssl${h2www ? ' http2' : ''}; server_name www.example.com; ${SSL} return 301 https://example.com$request_uri; } # 3. HTTPS, example.com: the site server { listen 443 ssl${h2main ? ' http2' : ''}; listen [::]:443 ssl${h2main ? ' http2' : ''}; server_name example.com; ${SSL} root /var/www/example.com; index index.html; }` const write = (body) => `sudo tee ${FILE} > /dev/null <<'EOF'\n${body}\nEOF` const check = (ctx) => { if (!VPS) { ctx.check('this check runs on a real rented server (LIVE_VPS and LIVE_VPS_DOMAIN set)', false, 'LIVE_VPS is not set') return } return bareBox(ctx, async ({ sudoUser }) => { const { run, L } = sudoUser() const rc = (cmd, opts = {}) => run(cmd.replace(/curl /g, `curl${K} `), { show: cmd, ...opts }) L('sudo true') // ── hidden: as the UFW, Nginx, Let's Encrypt and redirect articles leave the server ────────── L('sudo ufw allow OpenSSH && sudo ufw --force enable') L('sudo apt-get update -qq && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq nginx certbot python3-certbot-nginx', 900000) L("sudo ufw allow 'Nginx Full'") L("sudo mkdir -p /var/www/example.com && echo '

example.com works

' | sudo tee /var/www/example.com/index.html") L(`${write('server {\n listen 80;\n listen [::]:80;\n server_name example.com www.example.com;\n root /var/www/example.com;\n index index.html;\n}')}\nsudo ln -s ${FILE} /etc/nginx/sites-enabled/ && sudo systemctl reload nginx`) const got = L(le('sudo certbot --nginx -d example.com -d www.example.com --non-interactive --agree-tos -m admin@example.com --no-eff-email'), 300000) ctx.check('(setup) certbot got a certificate for example.com and www.example.com', /Successfully deployed certificate for www\.example\.com/.test(got), got) L(`${write(blocks(false, false))}\nsudo nginx -t && sudo systemctl reload nginx`) // ── step 1: what the site speaks now ───────────────────────────────────────────────────── const v1 = rc(`curl -sI https://example.com -o /dev/null -w '%{http_version}\\n'`, { id: 'version-before' }) ctx.check('before: curl talks HTTP/1.1 to https://example.com (curl offers h2; the server does not)', v1.out.trim() === '1.1', v1.out) const mods = run(`nginx -V 2>&1 | grep -oE 'http_v[23]_module'`, { id: 'modules' }) const has3 = /http_v3_module/.test(mods.out) if (!NEW) ctx.check('Ubuntu’s nginx is built with http_v2_module and without http_v3_module', mods.out.trim() === 'http_v2_module', mods.out) else ctx.check(`Ubuntu’s nginx is built with http_v2_module${has3 ? ' and http_v3_module' : ', without http_v3_module'}`, /http_v2_module/.test(mods.out), mods.out) const NV = (L("dpkg-query -W -f='${Version}' nginx").match(/^(\d+\.\d+\.\d+)/) ?? [])[1] ?? '?' const ver = run('nginx -v', { id: 'nginx-version' }) ctx.check(`nginx -v: nginx/${NV} (Ubuntu)`, ver.out.includes(`nginx/${NV} (Ubuntu)`), ver.out) // ── step 2: turn HTTP/2 on ─────────────────────────────────────────────────────────────── if (NEW) { // nginx 1.25.1+: one directive in the http block (conf.d is read inside it) turns it on for every server const w = run(`echo 'http2 on;' | sudo tee /etc/nginx/conf.d/http2.conf`, { id: 'http2-on-write' }) ctx.check('tee prints the line it wrote: `http2 on;`', w.out.trim() === 'http2 on;', w.out) const t1 = run('sudo nginx -t', { id: 'test' }) ctx.check('nginx -t is successful with `http2 on;`', t1.exit === 0 && /test is successful/.test(t1.out), t1.out) run('sudo systemctl reload nginx', { id: 'reload' }) } else { const g1 = run(`grep -n 'listen' ${FILE}`, { id: 'listen-before' }) ctx.check('the file has four `listen … 443 ssl;` lines (two HTTPS blocks, IPv4 + IPv6)', (g1.out.match(/443 ssl;/g) ?? []).length === 4, g1.out) run(`sudo cp ${FILE} ~/example.com.before-http2`, { id: 'backup' }) run(`sudo sed -i 's/listen \\(.*\\)443 ssl;/listen \\1443 ssl http2;/' ${FILE}`, { id: 'sed-http2' }) const g2 = run(`grep -n 'listen' ${FILE}`, { id: 'listen-after' }) ctx.check('after sed: all four 443 lines read `443 ssl http2;`, the port-80 lines are unchanged', (g2.out.match(/443 ssl http2;/g) ?? []).length === 4 && (g2.out.match(/listen (\[::\]:)?80;/g) ?? []).length === 2, g2.out) const t1 = run('sudo nginx -t', { id: 'test' }) ctx.check('nginx -t is successful', t1.exit === 0 && /test is successful/.test(t1.out), t1.out) run('sudo systemctl reload nginx', { id: 'reload' }) } // ── step 3: check it ───────────────────────────────────────────────────────────────────── const v2 = rc(`curl -sI https://example.com -o /dev/null -w '%{http_version}\\n'`, { id: 'version-after' }) ctx.check('after: curl talks HTTP/2 to https://example.com', v2.out.trim() === '2', v2.out) const h = rc(`curl -sI https://example.com | head -n 1`, { id: 'status-line' }) ctx.check('the status line is `HTTP/2 200`', /^HTTP\/2 200/.test(h.out.trim()), h.out) const w = rc(`curl -sI https://www.example.com | head -n 1`, { id: 'status-www' }) ctx.check('the www redirect also answers over HTTP/2: `HTTP/2 301`', /^HTTP\/2 301/.test(w.out.trim()), w.out) const alpn = run(`echo | openssl s_client -connect example.com:443 -servername example.com -alpn h2 2>/dev/null | grep -a ALPN`, { id: 'alpn' }) ctx.check('openssl: the TLS handshake picks `ALPN protocol: h2`', /ALPN protocol: h2/.test(alpn.out), alpn.out) const out1 = fromOutside('https://example.com/') ctx.check('(from another network) curl gets HTTP/2 200', out1 === '2 200', out1) const p80 = rc(`curl -sI http://example.com | head -n 1`, { id: 'http-plain' }) ctx.check('plain http stays HTTP/1.1 (the redirect): `HTTP/1.1 301 Moved Permanently`', /^HTTP\/1\.1 301 Moved Permanently/.test(p80.out.trim()), p80.out) if (NEW) { // ── the old `listen … http2` form on nginx 1.25.1+ ───────────────────────────────────── run(`sudo cp ${FILE} ~/example.com.before-http2`, { id: 'backup' }) run(`sudo sed -i 's/listen \\(.*\\)443 ssl;/listen \\1443 ssl http2;/' ${FILE}`, { id: 'sed-http2' }) const td = run('sudo nginx -t', { id: 'test-deprecated' }) ctx.check('the old form `listen 443 ssl http2;` still loads, with [warn] the "listen ... http2" directive is deprecated', td.exit === 0 && /\[warn\].*"listen \.\.\. http2" directive is deprecated, use the "http2" directive instead/.test(td.out) && /test is successful/.test(td.out), td.out) run(`sudo cp ~/example.com.before-http2 ${FILE}`, { id: 'restore' }) const tr = L('sudo nginx -t 2>&1') ctx.check('(the backup restored, nginx -t is successful with no warning)', /test is successful/.test(tr) && !/deprecated/.test(tr), tr) L('sudo systemctl reload nginx') } else { // ── `http2 on;` is for nginx 1.25.1 and later ──────────────────────────────────────────── run(`echo 'http2 on;' | sudo tee /etc/nginx/conf.d/http2.conf`, { id: 'http2-on-write' }) const t2 = run('sudo nginx -t', { id: 'http2-on-test' }) ctx.check('`http2 on;` on nginx 1.24: [emerg] unknown directive "http2", test failed', t2.exit !== 0 && /unknown directive "http2" in \/etc\/nginx\/conf\.d\/http2\.conf:1/.test(t2.out) && /test failed/.test(t2.out), t2.out) run('sudo rm /etc/nginx/conf.d/http2.conf', { id: 'http2-on-rm' }) const t3 = L('sudo nginx -t 2>&1') ctx.check('(the file removed, nginx -t is successful again)', /test is successful/.test(t3), t3) // ── per address and port: one block with http2 turns it on for all on 443 ──────────────── L(`${write(blocks(false, true))}`) const t4 = run('sudo nginx -t', { id: 'one-block-test' }) ctx.check('http2 in the main block only: nginx -t is successful', t4.exit === 0 && /test is successful/.test(t4.out), t4.out) L('sudo systemctl reload nginx') const w2 = rc(`curl -sI https://www.example.com | head -n 1`, { id: 'one-block-www' }) ctx.check('…and the www block, with no http2 on its lines, still answers HTTP/2 (same address and port)', /^HTTP\/2 301/.test(w2.out.trim()), w2.out) L(`${write(blocks(true, true))}\nsudo nginx -t && sudo systemctl reload nginx`) } // ── renewal keeps the lines ────────────────────────────────────────────────────────────── const dry = run(le('sudo certbot renew --dry-run'), { show: 'sudo certbot renew --dry-run', id: 'dry-run', timeout: 300000 }) ctx.check('certbot renew --dry-run succeeds', dry.exit === 0 && /Congratulations, all simulated renewals succeeded/.test(dry.out), dry.out) if (NEW) { const keep = run('cat /etc/nginx/conf.d/http2.conf', { id: 'conf-after-renew' }) ctx.check('…and /etc/nginx/conf.d/http2.conf is untouched (certbot edits only the site’s file)', keep.out.trim() === 'http2 on;', keep.out) } else { const cnt = run(`grep -c 'ssl http2' ${FILE}`, { id: 'count-after-renew' }) ctx.check('…and the four `ssl http2` lines are still there', cnt.out.trim() === '4', cnt.out) } const v3 = rc(`curl -sI https://example.com -o /dev/null -w '%{http_version}\\n'`, { id: 'version-after-renew' }) ctx.check('…and the site still answers HTTP/2', v3.out.trim() === '2', v3.out, { reader: { cmd: "curl -sI https:// -o /dev/null -w '%{http_version}\\n'", expect: '^2$' }, }) const tEnd = L('sudo nginx -t 2>&1') ctx.check('(the config tests clean at the end of the steps)', /test is successful/.test(tEnd), tEnd, { reader: { cmd: 'sudo nginx -t 2>&1', expect: 'test is successful' } }) ctx.stepsDone() // the article's steps end here; the undo follows reportBox( ctx, L, `A fresh Ubuntu ${RELEASE} cloud server from a hosting provider (its stock image, a public IPv4 address), with a domain and its www name pointed at it, ufw on, Nginx serving one site with a Let’s Encrypt certificate for both names and the www and HTTPS redirects, as the earlier articles leave it; reached over SSH as a sudo user. HTTP/2 was also checked from another network.`, ['nginx', 'openssl', 'certbot', 'python3-certbot-nginx', 'curl'], ) // ── undo ───────────────────────────────────────────────────────────────────────────────── if (NEW) run('sudo rm /etc/nginx/conf.d/http2.conf', { id: 'undo-rm' }) else run(`sudo sed -i 's/ ssl http2;/ ssl;/' ${FILE}`, { id: 'undo-sed' }) const tu = run('sudo nginx -t && sudo systemctl reload nginx', { id: 'undo-reload' }) ctx.check('undo: nginx -t successful', tu.exit === 0, tu.out) const vu = rc(`curl -sI https://example.com -o /dev/null -w '%{http_version}\\n'`, { id: 'version-undo' }) ctx.check('undo: back to HTTP/1.1', vu.out.trim() === '1.1', vu.out) // ── hidden: revoke the certificate the run got ─────────────────────────────────────────── const rv = L(le('sudo certbot revoke --cert-name example.com --non-interactive --delete-after-revoke'), 300000) ctx.check('(cleanup) the certificate the run got is revoked', /revoked/i.test(rv), rv) }) } export default check