HTTP/2 and HTTP/3 significantly improve page load performance over HTTP/1.1 by multiplexing requests over a single connection and reducing latency. Both require HTTPS to be enabled first.
Prerequisites
- Nginx installed with an active SSL certificate
- Nginx version 1.25+ for built-in HTTP/3 support (check with
nginx -v)
Enabling HTTP/2
Edit your site's SSL server block:
sudo nano /etc/nginx/sites-available/example.com
server {
listen 443 ssl;
http2 on;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
}
On older Nginx versions, the syntax is instead:
listen 443 ssl http2;
sudo nginx -t && sudo systemctl reload nginx
Verifying HTTP/2 Is Active
curl -I --http2 -s https://example.com | head -1
You should see HTTP/2 200. You can also check via browser developer tools (Network tab → Protocol column).
Enabling HTTP/3 (QUIC)
HTTP/3 runs over UDP rather than TCP, so it requires an additional listener and firewall rule:
server {
listen 443 ssl;
listen 443 quic reuseport;
http2 on;
http3 on;
add_header Alt-Svc 'h3=":443"; ma=86400';
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
}
Opening UDP Port 443 for QUIC
sudo ufw allow 443/udp
Verifying HTTP/3
curl -I --http3 https://example.com
Note this requires a curl build with HTTP/3 support; alternatively, check via browser developer tools or an external tool like HTTP/3 Check.
Common Errors
"unknown directive http3" — your Nginx build doesn't include HTTP/3 support; verify with nginx -V 2>&1 | grep -o with-http_v3_module, and upgrade to a build/version that includes it if missing.
HTTP/2 not showing in browser — confirm HTTPS is actually active on the connection being tested; HTTP/2 only applies over TLS in virtually all real-world Nginx configurations.
Best Practices
- Enable HTTP/2 on every HTTPS site — there's no real downside
- Treat HTTP/3 as an enhancement layered on top of working HTTP/2, not a replacement
- Confirm your hosting provider's network doesn't block UDP before troubleshooting HTTP/3 issues
FAQ
Do I need HTTP/3 if I already have HTTP/2?
Not strictly — HTTP/2 already provides most performance benefits; HTTP/3 further helps primarily on unstable/high-latency networks by avoiding TCP head-of-line blocking.
Related Articles
- How to Install Nginx on Ubuntu & Debian
- How to Install Let's Encrypt SSL with Certbot (Nginx & Apache)
- Nginx Performance Tuning: Worker Processes, Caching & Gzip
