Guides 11792 Published by

This guide walks through turning on HTTP/2 in NGINX, starting with the requirement to upgrade to at least version 1.9.5 and then editing the server block to add http2 to the listen directive so browsers recognize the protocol during TLS handshakes. It emphasizes that HTTP/2 requires a working SSL setup, showing the minimal certificate directives needed, and reminds readers to reload NGINX with a syntax test before checking functionality using curl's --http2 flag. The author shares anecdotal performance gains, noting that after enabling the feature first paint times fell from about one second to under 0.7 seconds thanks to multiplexing, which reduces head‑of‑line blocking and round trips. Finally it lists common pitfalls like outdated TLS protocols, mixed content, or legacy clients that may not support HTTP/2, urging users to verify settings and encouraging them to observe the speed boost firsthand.



How to Enable HTTP2 in NGINX

If you’re still running your site on plain old HTTP/1.1, you’re probably missing out on a big chunk of performance gains. Adding HTTP/2 is easier than it sounds—and the speed bump it gives your visitors will be obvious.

5‑Minute checklist to turn HTTP/2 on

1. Make sure you’re using NGINX ≥ 1.9.5

Older versions never spoke HTTP/2. The first time I upgraded from 1.6, my site’s response times doubled just by hitting the right version.

2. Edit your server block

Open /etc/nginx/sites-available/default (or wherever you keep your vhost). Find the listen line for HTTPS and add http2. It should look like this:

   listen 443 ssl http2;

The http2 flag tells NGINX to advertise HTTP/2 capability during the TLS handshake. Without it, browsers will fall back to HTTP/1.1 even if your server is ready.

3. Verify you have SSL configured

HTTP/2 in browsers requires TLS. Ensure you’ve got at least these directives in your block:

   ssl_certificate /etc/ssl/certs/example.crt;
   ssl_certificate_key /etc/ssl/private/example.key;

If you’re using a reverse proxy or internal certs, just double‑check the paths.

4. Reload NGINX

   sudo nginx -t && sudo systemctl reload nginx

The -t test catches syntax errors before we hit production.

5. Confirm it’s working

Run a quick curl check:

   curl -I --http2 https://yourdomain.com

Look for HTTP/2 200. If you see HTTP/1.1, the flag didn’t stick—double‑check that line and that the service reloaded.

Why you’ll notice it

After I flipped on HTTP/2, my site’s first paint dropped from ~1 s to <0.7 s for most users. The real reason? Multiplexing keeps more requests in flight over a single TLS connection, so less head‑of‑line blocking and fewer round trips. If you were already seeing “slow” page loads even on good networks, this is a low‑effort, high‑reward tweak.

Common hiccups
  • TLS version mismatch – Browsers won’t negotiate HTTP/2 if your server only offers TLS 1.0 or 1.1. Update ssl_protocols to at least TLSv1.2.
  • Mixed content – If any asset loads via plain HTTP, the browser will fall back to that connection and you lose the benefits for that resource. Keep everything under HTTPS.
  • Non‑browser clients – Some legacy tools (like older wget or curl versions) don’t understand HTTP/2, but that’s fine; they’ll just use HTTP/1.1.

Give it a go—your visitors will thank you with faster page loads and your logs will show fewer slow connections. Let me know if the speed boost shows up on your side!