Docs / Web Servers / How to Enable HTTP/2 and HTTP/3 on Nginx

How to Enable HTTP/2 and HTTP/3 on Nginx

By Admin · Feb 25, 2026 · Updated Apr 25, 2026 · 146 views · 1 min read

HTTP/2 Benefits

  • Multiplexing — multiple requests over a single connection
  • Header compression — reduces overhead
  • Server push — proactively send resources
  • Binary protocol — more efficient parsing

Enable HTTP/2 on Nginx

HTTP/2 requires SSL. 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;

    # Recommended SSL settings for HTTP/2
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers off;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 1d;
}

Verify HTTP/2

curl -I --http2 https://example.com
# Look for: HTTP/2 200

HTTP/3 (QUIC)

HTTP/3 uses UDP instead of TCP for faster connection establishment and better performance on lossy networks. Nginx added experimental HTTP/3 support in version 1.25.

server {
    listen 443 ssl;
    listen 443 quic reuseport;
    http2 on;
    http3 on;

    add_header Alt-Svc 'h3=":443"; ma=86400';
    ssl_early_data on;
}

Firewall for HTTP/3

# HTTP/3 uses UDP port 443
sudo ufw allow 443/udp

Performance Tips

  • Enable OCSP stapling to reduce SSL handshake time
  • Use TLS 1.3 for faster handshakes
  • Enable session tickets for connection resumption

Was this article helpful?