• Get application security done the right way! Detect, Protect, Monitor, Accelerate, and more…
  • HTTP/2 is the second major version HTTP protocol released in 2015.


    Since launch, around 11% of website support HTTP/2.

    It got many features like:

    • HTTP Header Compression
    • Push technologies
    • Load page elements in parallel over a single TCP connection
    • Binary protocol
    • Reduce latency

    Demo by AKAMAI shows HTTP/2 is approximately two times faster than HTTP/1.1

    Did you know LiteSpeed was one of the first web servers to support HTTP/2?

    If you are using CDN like Cloudflare, Incapsula, MaxCDN then you may not need to enable HTTP/2 in your web servers as you can do it from CDN network edge.

    However, if you need to implement HTTP/2 in your web servers like Apache, Nginx, IIS then here is how you can do that.

    Note: currently all browser support HTTP/2 protocol over HTTPS only. Your web server must be configured with SSL certificate to support HTTP/2.

    But don’t worry if you are doing some experiment, you can get the SSL certificate in FREE.

    Implement HTTP/2 in Apache HTTP

    HTTP/2 can be deployed in Apache HTTP 2.4.17 or later version with the help of mod_http2 module. So if you have 2.2 or lower version then first you got to upgrade to the compatible version.

    Let’s compile Apache HTTP with the mod_http2, mod_ssl module.

    • Download the latest version (I’ll do 2.4.25 on Linux)
    • Extract the downloaded file, if you downloaded .gz file then
    gunzip -c httpd-2.4.25.tar.gz | tar xvf -
    • You will see a new folder create, go inside that
    • Build the Apache from source with configure command

    Note: if you are trying this on a brand new server then you may encounter an error to install dependencies, and this guide should help you with that.

    ./configure --enable-ssl --enable-so --enable-http2
    • Ensure no error from above command once done, execute the following make command
    make install

    This concludes Apache HTTP is installed with HTTP/2 module and it’s time to do the necessary configuration.

    • Take a backup of httpd.conf file (default location /etc/httpd/conf/httpd.conf)
    • Open the httpd.conf file with vi and ensure following exist, if not then add it.
    LoadModule http2_module modules/mod_http2.so
    • Next, you need to add the Protocols directive like below
    Protocols h2 h2c http/1.1

    If you are enabling HTTP/2 for an individual virtual host, then you need to add Protocols under respective VIrtualHost.

    Note: there are three parameters in the above Protocols directive

    • h2 – instructing Apache to support HTTP/2 protocol over SSL/TLS
    • h2c – instructing Apache to support HTTP/2 over TCP
    • http/1.1 – if a client doesn’t accept HTTP/2 then serve the request over HTTP/1.1

    Restart Apache HTTP server to reload the configuration.

    Now, Apache HTTP instance is enabled to support HTTP/2 protocol.

    Implement HTTP/2 in Nginx

    Nginx 1.9.5 or higher version support HTTP/2 so first you got to ensure you have the compatible version installed.

    Enabling HTTP/2 in Nginx is just a matter of adding http2 parameter in listen directive.

    • As usual, take a backup of nginx.conf file (default location /etc/nginx/nginx.conf)
    • Modify using vi and add http2 under listen directive
    server {
            listen       443 http2 ssl chandan.io;

    As I mentioned above, HTTP/2 is supported only over HTTPS, so you got to add under server block which has SSL configuration.

    If your SSL configuration is in another file than nginx.conf, then you got to update there.

    Once done, restart the Nginx for configuration to be active.

    Verify if Website Support HTTP/2

    There are multiple ways to check if the website supports HTTP/2 or not.

    Manually – open IE/Chrome/Firefox and press F12 >> go to network tab and you should see protocol as HTTP/2

    Online – you can use HTTP/2 Test tool

    That’s all for today. I hope above helps you to enable HTTP/2 protocol in Apache and Nginx web server for fast loading web pages.