HTTP/2 Benefits
- Multiplexing — multiple requests over a single connection
- Header compression — reduces overhead
- Server push — proactively send resources
Enable HTTP/2
HTTP/2 requires HTTPS. Simply add http2 to your listen directive:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# SSL optimization
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_protocols TLSv1.2 TLSv1.3;
}Enable HTTP/3 (QUIC)
HTTP/3 uses QUIC (UDP-based). Requires Nginx 1.25+ or OpenResty:
server {
listen 443 ssl;
listen 443 quic reuseport;
http2 on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# Advertise HTTP/3 support
add_header Alt-Svc 'h3=":443"; ma=86400';
}Ensure UDP port 443 is open in your firewall:
sudo ufw allow 443/udpVerify
# Check HTTP/2
curl -I --http2 https://example.com
# Check via browser DevTools → Network → Protocol column