HTTP/2 lets a browser fetch many files over one connection instead of opening a new connection per file, which cuts load time on pages with lots of CSS, JavaScript, and images. Enabling http/2 on nginx takes one directive in the right place, but a missed OpenSSL version, a plain HTTP listener, or a weak TLS setting can leave the directive in place with HTTP/2 still off. Work through this checklist in order, and test at each step instead of changing everything at once.
Checklist at a glance
- Confirm your Nginx build includes HTTP/2 and ALPN support.
- Install a valid TLS certificate for the domain.
- Add
http2to the HTTPS listen directive. - Set TLS 1.2 as the floor and prefer TLS 1.3.
- Test with curl and a browser, then check the error log.
- Keep an HTTP/1.1 fallback path for old clients.
Step 1: Enabling http/2 on nginx starts with the build check
HTTP/2 over the public internet runs over TLS, and Nginx negotiates it with ALPN during the TLS handshake. That needs Nginx built with the HTTP/2 module and OpenSSL 1.0.2 or newer. Check both before you touch any config:
nginx -V 2>&1 | grep -o 'with-http_v2_module'
openssl version
If the first command prints with-http_v2_module, the module is present. If it prints nothing, your Nginx build lacks HTTP/2, and you need a different package or a rebuild before this checklist can proceed. Most current distro packages and the official Nginx repo builds already include it, so a missing module usually means a very old install or a custom build that left it out.
Checklist item: module present, OpenSSL 1.0.2 or newer confirmed. If either check fails, stop here and fix the build first. Adding the directive to a build without the module produces a startup error, and adding it to a build without ALPN support leaves browsers on HTTP/1.1 with no warning in the page itself.
Step 2: Get a valid TLS certificate first
HTTP/2 on Nginx only applies to HTTPS listeners. A site still served over plain HTTP cannot turn on HTTP/2 for browsers, no matter what the config says. If you have no certificate yet, follow the guide to install a free Let’s Encrypt certificate with Certbot, then return to this checklist. Certbot writes the certificate paths and the SSL directives into your server block, which saves you from hand-editing paths.
After Certbot runs, confirm the certificate covers the exact domain in the server block, including www if you serve it. A certificate mismatch pushes browsers to a warning page before HTTP/2 ever matters. Also set up renewal now, not later: the guide on how to renew Let’s Encrypt certificates automatically covers the timer check that stops expiry downtime. An expired certificate breaks the site for every visitor, HTTP/2 or not.
Checklist item: certificate issued, paths present in the server block, renewal timer active. Run sudo certbot certificates and confirm the expiry date is in the future.
Step 3: Update the http2 server block
This is the core change. In the HTTPS server block, add http2 to the listen directive. The http2 server block change is small on purpose: one parameter, on the port 443 line only.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
}
Do not add http2 to the port 80 listener. Nginx will reject it or ignore it depending on version, and plain HTTP stays HTTP/1.1 by design. Keep the port 80 block as a redirect to HTTPS:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}
The nginx http2 listen directive is listen 443 ssl http2; on Nginx 1.25.1 and newer, and the same line works on older 1.9.5+ builds. On Nginx 1.25.1 and newer, http2 moved from a standalone directive to a listen parameter, so if you find an old guide telling you to add http2 on; as its own line, that applies only to newer builds in a different form. Match the form to your installed version, which you already confirmed in step 1.
Checklist item: http2 present on both IPv4 and IPv6 HTTPS listeners, absent from port 80, config test passes with sudo nginx -t.
Step 4: Tune the tls configuration nginx uses for HTTP/2
HTTP/2 has a blocklist of weak TLS ciphers, and a server that offers them can cause browsers to refuse the connection. Set TLS versions and ciphers explicitly instead of leaving distro defaults in place. The comparison of TLS 1.2 vs TLS 1.3 explains why TLS 1.3 is preferred and TLS 1.2 stays as the floor for older clients.
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
With TLS 1.3, the server does not choose ciphers in the old sense, so ssl_prefer_server_ciphers off is the correct setting there. Keep TLS 1.0 and 1.1 off: they add no value for modern browsers and weaken the handshake. If a subdomain needs a wildcard certificate, the guide to set up Let’s Encrypt wildcard certificates with DNS validation covers the DNS challenge flow that the HTTP challenge cannot do.
Checklist item: TLS 1.2 and 1.3 only, session cache set, no TLS 1.0 or 1.1 left in the block. Reload with sudo systemctl reload nginx after the edit, not restart, so existing connections stay alive.
Step 5: Run the http2 test curl check and a browser check
Verify from the server itself first. The http2 test curl command asks for HTTP/2 explicitly and reports the protocol actually used:
curl -I --http2 https://example.com
Look at the first line of the output. HTTP/2 200 means HTTP/2 is live. HTTP/1.1 200 means the request fell back: re-check the listen line, confirm you reloaded, and confirm you tested the HTTPS URL and not the HTTP one. Curl needs a build with HTTP/2 support for this test; if your curl is very old, test in a browser instead and do not trust a HTTP/1.1 result from an old curl alone.
In a browser, open DevTools, go to the Network tab, right-click the column headers, and add the Protocol column. Reload the page. Requests served over HTTP/2 show h2 in that column. Check a few asset types, not just the HTML document, because a CDN or a second domain in the page can still serve over HTTP/1.1 while your origin serves h2.
Checklist item: curl reports HTTP/2 200, browser Protocol column shows h2 for same-origin assets, error log at /var/log/nginx/error.log shows no new TLS or HTTP/2 errors after reload.
Step 6: Confirm the speed gain and keep the fallback
HTTP/2 helps most on pages with many small files. Measure before and after with the same tool and the same page, or the comparison means nothing. A simple before-and-after check is enough for a small site: total load time in DevTools on a throttled connection, plus time to first byte. For WordPress sites chasing a faster first paint, the guide to reduce WordPress TTFB covers the server-side fixes that matter more than protocol version alone, such as caching and PHP worker tuning.
Keep the HTTP/1.1 fallback in place by doing nothing extra: browsers that cannot negotiate HTTP/2 fall back to HTTP/1.1 automatically over the same TLS connection. Do not block old clients, and do not force HTTP/2-only handling in the config. If a specific old client or proxy reports errors after the change, the fallback path is the first thing to test by forcing HTTP/1.1 in curl with curl -I --http1.1 https://example.com and comparing the result.
Common misses, in the order they show up in practice: the directive added to port 80 instead of 443, a reload skipped after the edit, a certificate that covers the apex but not www, and a second server block for the same domain that still lacks http2 and answers first. When two server blocks share a domain, Nginx uses the first match, so grep the whole config directory for the domain and fix every matching block.
Checklist item: speed measured on the same page before and after, fallback confirmed with an HTTP/1.1 curl test, every server block for the domain checked. Once all six steps pass, HTTP/2 is on and verified, not just configured.