HTTP/2 is the second major version of the HTTP protocol, standardised in 2015, and offers significant performance improvements over HTTP/1.1: header compression (HPACK), multiplexing (multiple requests over a single connection), server push, and binary framing. On a typical webpage with dozens of assets (CSS, JavaScript, images, fonts), HTTP/2 multiplexing eliminates the head-of-line blocking that forces HTTP/1.1 clients to open multiple parallel TCP connections. The result is measurably faster page loads, especially over high-latency connections. Nginx has supported HTTP/2 since version 1.9.5, and on RHEL 9 enabling HTTP/2 requires only adding http2 to the listen directive on your SSL server block. This guide also covers verifying HTTP/2 is active, enabling HTTP/2 push, and disabling HTTP/2 for specific locations.
Prerequisites
- Nginx installed on RHEL 9 with a working HTTPS server block
- A valid SSL certificate (from Let’s Encrypt or other CA)
HTTP/2 requires HTTPS — browsers will not use HTTP/2 over plain HTTP.
Step 1 — Enable HTTP/2 in Nginx
Add http2 to the listen directives in your HTTPS server block:
vi /etc/nginx/conf.d/example.com.conf
server {
listen 443 ssl http2; # Add http2 here
listen [::]:443 ssl http2; # And for IPv6
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
# TLS 1.2 is required for HTTP/2 compatibility
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
root /var/www/example.com/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
nginx -t && systemctl reload nginx
Step 2 — Verify HTTP/2 is Active
# Using curl (--http2 flag)
curl -I --http2 https://example.com
# Output should show: HTTP/2 200
# Use openssl to inspect the ALPN negotiation
openssl s_client -connect example.com:443 -alpn h2 2>/dev/null | grep ALPN
# Expected output: ALPN protocol: h2
# Using nghttp (install with: dnf install nghttp2)
dnf install -y nghttp2
nghttp -v https://example.com 2>&1 | grep "HTTP/2"
Step 3 — Configure HTTP/2 Performance Settings
# Add inside the http {} block in /etc/nginx/nginx.conf
http {
# Maximum number of requests per HTTP/2 connection
http2_max_requests 1000;
# Push preload headers automatically
http2_push_preload on;
}
Step 4 — HTTP/2 Server Push
Server push proactively sends resources the client will need (CSS, JS) before the client requests them:
location = /index.html {
http2_push /css/main.css;
http2_push /js/app.js;
http2_push /fonts/roboto.woff2;
}
Alternatively, use Link headers in your application responses and Nginx will push them automatically with http2_push_preload on:
# Application sets: Link: ; rel=preload; as=style
# Nginx sees this header and pushes /css/main.css proactively
Step 5 — Verify with Chrome DevTools
Open Chrome DevTools (F12) → Network tab → right-click a column header → enable “Protocol”. Reload the page — assets served over HTTP/2 will show h2 in the Protocol column. HTTP/1.1 assets show http/1.1.
Step 6 — Verify Nginx was Compiled with HTTP/2 Support
nginx -V 2>&1 | grep http_v2_module
The output should include --with-http_v2_module. The RHEL 9 AppStream Nginx is compiled with HTTP/2 support by default.
Troubleshooting
- curl shows HTTP/1.1 even after adding http2 — ensure you are connecting over HTTPS. HTTP/2 over plain HTTP (h2c) is not supported by most browsers and is disabled in Nginx by default.
- HTTP/2 reverts to HTTP/1.1 for some clients — this is expected. Older clients that do not advertise h2 ALPN support will negotiate HTTP/1.1. Both protocols coexist on the same listener.
Conclusion
HTTP/2 is enabled on your Nginx RHEL 9 server with a single keyword addition to the listen directive. All modern browsers will automatically negotiate HTTP/2 via ALPN, experiencing faster page loads through header compression and multiplexing. Server push gives you additional performance gains for critical assets.
Next steps: How to Configure Nginx Load Balancing on RHEL 9, How to Enable Brotli and Gzip Compression in Nginx on RHEL 9, and How to Harden Nginx: Security Headers and TLS 1.3 on RHEL 9.