
HTTP/2 makes websites faster. It allows multiple requests over a single connection, compresses headers, and enables server push. If you're still running HTTP/1.1, you're leaving performance on the table.
Here's how to enable HTTP/2 on the most common server setups.
HTTP/2 requires HTTPS. If you don't have SSL configured yet, set that up first. Let's Encrypt makes this free and straightforward.
Nginx has supported HTTP/2 since version 1.9.5. Enabling it takes one line change.
Open your server block configuration:
sudo nano /etc/nginx/sites-available/default
Find your listen directive and add http2:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
# ... rest of config
}
Test and reload:
sudo nginx -t
sudo systemctl reload nginx
Apache 2.4.17+ supports HTTP/2 through mod_http2.
Enable the module:
sudo a2enmod http2
Add the protocol directive to your virtual host:
<VirtualHost *:443>
Protocols h2 h2c http/1.1
SSLEngine on
SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /path/to/key.pem
# ... rest of config
</VirtualHost>
Restart Apache:
sudo systemctl restart apache2
Caddy enables HTTP/2 by default. If you're using Caddy, you're already done. It also handles SSL automatically.
example.com {
root * /var/www/html
file_server
}
That's it. HTTP/2 and HTTPS are enabled out of the box.
LiteSpeed also enables HTTP/2 by default on HTTPS connections. No configuration needed.
To verify it's working, check the LiteSpeed admin panel under Configuration → Server → Tuning → Enable HTTP/2.
Once configured, verify it's working:
Browser DevTools:
Open Chrome DevTools, go to the Network tab, right-click the header row, and enable "Protocol". You should see h2 for HTTP/2 connections.
Command line:
curl -I --http2 https://yourdomain.com
Look for HTTP/2 200 in the response.
Online tools: KeyCDN HTTP/2 Test gives you a quick check.
HTTP/2 not working despite configuration:
Mixed protocol issues:
PHP-FPM conflicts (Apache):
HTTP/2 changes some best practices:
Need a server that's already optimized? Our VPS plans come with modern web servers pre-configured for HTTP/2 and HTTP/3. Check out our options.