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!