// Web Development

How to Configure HTTP/2 on Nginx and Apache: Complete Guide for Web Performance — CLIQHOST

October 08, 2026 · by Alex M.

How to Configure HTTP/2 on Nginx and Apache: Complete Guide for Web Performance — CLIQHOST

HTTP/2 is the modern version of the HTTP protocol, officially adopted in 2015 and supported today by all major browsers. Compared to HTTP/1.1, it brings significant improvements: request multiplexing, header compression (HPACK), Server Push, and resource prioritization. The practical result: your website loads faster, with lower latency and less connection overhead.

In this guide you will learn how to enable and configure HTTP/2 on Nginx and Apache on a Linux server (Ubuntu 22.04 / Debian 12), including how to verify that everything is working correctly. If you have a CLIQHOST NVMe VPS or a dedicated server, you can apply the steps below directly.


Why Does HTTP/2 Matter for Your Website?

Before diving into configuration, it's worth understanding the concrete differences from its predecessor:

Feature HTTP/1.1 HTTP/2
Connections per domain 6–8 parallel (browser) 1 connection, multiplexed
Header compression No Yes (HPACK)
Server Push No Yes
Format Text Binary
Latency High (head-of-line blocking) Low

In practice, a website that served 80 resources via HTTP/1.1 with 6 parallel connections can now serve them through a single TCP connection without blocking. The impact is especially visible on high-latency connections (mobile networks, international connections).

Important: HTTP/2 requires HTTPS. Make sure you have an active SSL certificate before proceeding.


HTTP/2 on Nginx

1. Check the Nginx Version

HTTP/2 is supported starting from Nginx 1.9.5. On Ubuntu 22.04, the repository version is sufficient:

nginx -v
# nginx version: nginx/1.18.0 (Ubuntu)

For the latest stable version, add the official Nginx repository:

curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor -o /usr/share/keyrings/nginx.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx.gpg] http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" \
  | sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt update && sudo apt install nginx -y

2. Enable HTTP/2 in the server Block

Open your site's configuration file:

sudo nano /etc/nginx/sites-available/example.com

Modify the listen directive as follows:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    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;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    root /var/www/example.com/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://$host$request_uri;
}

In Nginx 1.25.1+, the syntax changed: http2 becomes a standalone directive (http2 on;) rather than part of listen. Check your version's documentation.

3. Test and Reload the Configuration

sudo nginx -t
sudo systemctl reload nginx

4. Additional HTTP/2 Optimizations for Nginx

Add the following to the http block in /etc/nginx/nginx.conf:

http {
    http2_push_preload on;          # enables Server Push via Link header
    keepalive_timeout 65;
    keepalive_requests 1000;

    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
}

Server Push proactively sends critical resources (CSS, JS) before the browser requests them. You can enable push per location:

location = /index.html {
    http2_push /css/main.css;
    http2_push /js/app.js;
}

Or via HTTP header (more flexible, controlled from the application):

Link: </css/main.css>; rel=preload; as=style

HTTP/2 on Apache

1. Prerequisites

Apache supports HTTP/2 through the mod_http2 module, available since version 2.4.17. On Ubuntu 22.04, the standard version 2.4.52 is sufficient.

apache2 -v
# Server version: Apache/2.4.52 (Ubuntu)

MPM prefork (the default on many systems) is not compatible with HTTP/2. You need to use MPM event or MPM worker.

2. Switch MPM to event

sudo a2dismod mpm_prefork
sudo a2enmod mpm_event

If you use PHP via mod_php, you need to switch to PHP-FPM:

sudo apt install php8.2-fpm -y
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.2-fpm

3. Enable the mod_http2 Module

sudo a2enmod http2

4. Configure the VirtualHost

Open your site's configuration file:

sudo nano /etc/apache2/sites-available/example.com-le-ssl.conf

Add the Protocols directive to the SSL VirtualHost block:

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public

    Protocols h2 h2c http/1.1

    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

    SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
    SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256
    SSLHonorCipherOrder off
    SSLSessionTickets off

    <Directory /var/www/example.com/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / https://example.com/
</VirtualHost>

h2 = HTTP/2 over TLS; h2c = HTTP/2 in cleartext (limited browser support); http/1.1 = fallback.

5. Test and Restart Apache

sudo apache2ctl configtest
sudo systemctl restart apache2

6. Additional HTTP/2 Optimizations for Apache

Add to apache2.conf or the VirtualHost file:

# H2 parameters
H2Direct on
H2MaxSessionStreams 100
H2StreamMaxMemSize 65536
H2WindowSize 65535

# Server Push
<FilesMatch "index\.html$">
    Header add Link "</css/main.css>; rel=preload; as=style"
    Header add Link "</js/app.js>; rel=preload; as=script"
</FilesMatch>

Make sure the headers and rewrite modules are active:

sudo a2enmod headers rewrite
sudo systemctl reload apache2

How to Verify HTTP/2 Is Active?

Method 1: curl

curl -I --http2 https://example.com

Look for this in the output:

HTTP/2 200

Method 2: Browser Developer Tools

In Chrome/Firefox, open DevTools → Network, add the "Protocol" column (right-click on the column header). HTTP/2 requests appear as h2.

Method 3: Online Tool

Use https://tools.keycdn.com/http2-test — enter your domain and confirm HTTP/2 support.

Method 4: nghttp2

sudo apt install nghttp2-client -y
nghttp -nv https://example.com 2>&1 | grep "The negotiated protocol"
# The negotiated protocol: h2

Common Issues and Solutions

HTTP/2 Not Activating on Apache

  • Most common cause: MPM prefork is active. Check with apachectl -V | grep MPM. If you see prefork, follow the steps above to switch to event.
  • mod_ssl inactive: Run sudo a2enmod ssl and restart Apache.
  • OpenSSL too old: HTTP/2 requires TLS 1.2+ with ALPN. Check with openssl version.

Nginx Ignores the http2 Directive

  • Verify the configuration file is correctly included in nginx.conf.
  • Ensure there is no other server block listening on port 443 without http2.

WordPress Not Benefiting from HTTP/2

If your site runs on CLIQHOST WordPress hosting, HTTP/2 may already be active at the server level. Verify with curl as shown above. On a VPS SSD, you have full control to apply all the configurations in this guide.


HTTP/2 on cPanel / Shared Hosting

If you use a CLIQHOST shared cPanel hosting plan, enabling HTTP/2 is done at the server level — not from your cPanel account. Contact the CLIQHOST support team to verify whether HTTP/2 is enabled on your server and for additional assistance.

On our cPanel servers, HTTP/2 is enabled by default for all hosting plans that have an active SSL certificate.


HTTP/3 / QUIC — The Next Step

HTTP/3 (based on Google/IETF's QUIC protocol) is already supported in Nginx 1.25+ and some Apache builds. Unlike HTTP/2 (TCP), HTTP/3 uses UDP, completely eliminating transport-level blocking.

Enabling HTTP/3 on Nginx (experimental):

listen 443 quic reuseport;
listen 443 ssl http2;
add_header Alt-Svc 'h3=":443"; ma=86400';

HTTP/3 requires Nginx compiled with QUIC support (--with-http_v3_module). On CLIQHOST managed dedicated servers, our team can configure the complete HTTP/3 stack on request.


Final Checklist: HTTP/2 Configured Correctly

  • Valid and active SSL certificate
  • Nginx: http2 directive present in listen 443
  • Apache: MPM event active, mod_http2 enabled, Protocols h2 http/1.1 in VirtualHost
  • TLS 1.2 or 1.3 configured (without TLS 1.0 / 1.1)
  • Verified with curl -I --http2 — response is HTTP/2 200
  • Server Push configured for critical resources (optional but recommended)
  • Gzip / Brotli compression enabled alongside HTTP/2

Conclusion

HTTP/2 is today a baseline requirement for any high-performance website — not a luxury. Enabling it on Nginx or Apache takes less than 15 minutes and delivers real speed gains, especially for sites with many static resources.

If you want to benefit from an already optimized environment without the hassle, explore CLIQHOST NVMe VPS plans with fast SSDs and generous bandwidth, or check out our server management services if you prefer to leave the technical configurations to us.

For more practical guides on web server optimization, visit the CLIQHOST blog.

SHARE
// what clients say

What Our Clients Say

Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.

★★★★★

"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."

AM
Andrei M.
eCommerce owner · Chișinău
★★★★★

"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."

EV
Elena V.
Web agency · Bălți
★★★★★

"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."

DC
Dmitri C.
SaaS founder · Chișinău