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

How to Enable HTTP/2 and HTTP/3 on Your Web Server

By Admin · Mar 15, 2026 · Updated Apr 23, 2026 · 331 views · 2 min read

HTTP/2 and HTTP/3 significantly improve web performance through multiplexing, header compression, and server push. HTTP/3 uses QUIC (UDP-based) for even faster connections. This guide covers enabling both protocols on Nginx.

HTTP/2 Benefits

  • Multiplexing — Multiple requests over a single connection
  • Header compression (HPACK) — Reduces overhead
  • Stream prioritization — Important resources load first
  • Binary protocol — More efficient than text-based HTTP/1.1

Enabling HTTP/2 in Nginx

# Simply add http2 to the 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_protocols TLSv1.2 TLSv1.3;
}

sudo nginx -t && sudo systemctl reload nginx

HTTP/3 (QUIC) Benefits

  • 0-RTT connection establishment (even faster than HTTP/2)
  • Built on UDP — eliminates TCP head-of-line blocking
  • Better performance on lossy/mobile networks
  • Connection migration (survives network changes)

Enabling HTTP/3 in Nginx

# Requires Nginx 1.25+ compiled with QUIC support
# Check if your Nginx supports QUIC
nginx -V 2>&1 | grep quic

# Configuration
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    listen 443 quic;
    listen [::]:443 quic;

    http2 on;
    http3 on;

    # Tell clients HTTP/3 is available
    add_header Alt-Svc 'h3=":443"; ma=86400';

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
}

# Open UDP port 443 in firewall (QUIC uses UDP)
sudo ufw allow 443/udp

Verifying HTTP/2 and HTTP/3

# Check HTTP/2
curl -v --http2 https://example.com 2>&1 | grep "HTTP/2"

# Check HTTP/3 (requires curl 7.86+)
curl -v --http3 https://example.com 2>&1 | grep "HTTP/3"

# Online tools:
# https://http3check.net
# https://tools.keycdn.com/http2-test

# Browser DevTools:
# Open Network tab, add "Protocol" column
# Should show h2 (HTTP/2) or h3 (HTTP/3)

Performance Optimization

# HTTP/2 specific tuning
http2_max_concurrent_streams 128;
http2_recv_buffer_size 256k;

# Connection coalescing
# Multiple domains on the same certificate share one connection
# Use a wildcard certificate: *.example.com

# Early hints (103 status)
# Tell browser about critical resources before the full response
location / {
    add_header Link "; rel=preload; as=style" early;
    add_header Link "; rel=preload; as=script" early;
}

Was this article helpful?