How to Enable HTTP/2.0 Support on Nginx Web Server

HTTP/2 is the first major HTTP protocol update since 1997 when HTTP/1.1 was first published by the IETF. HTTP/2 (originally named HTTP/2.0) is the second major version of the HTTP network protocol which was released by Internet Engineering Task Force (IETF) HTTP Working Group.

It’s based on SPDY, SPDY (pronounced speedy) is an open networking protocol developed by Google to serve web content with reducing web page load, latency and improving web security. This can be achieved through compression, multiplexing, and prioritization.

[ac-button size=”large” color=”orange” style=”flat” icon=”fa-link” url=”https://www.2daygeek.com/how-to-enable-http2-0-support-on-apache-web-server/” target=”_blank”]How to Enable HTTP/2.0 Support on Apache Web Server[/ac-button]

On February 17, 2015 HTTP/2 was approved and May 14, 2015 published. HTTP/2 was integrated with Nginx 1.9.5 version by adding the core module ngx_http_v2_module. Almost, all the web browser started supporting HTTP/2 such as Chrome, Opera, Firefox, Internet Explorer 11 & Safari. As of November 2015 2.3% of the top 10 million websites supported HTTP/2.

HTTP/2 will support HTTP & HTTPS but most of the browsers only support https with HTTP/2. If you want to avail advantages & performance benefits of HTTP/2 better migrate to HTTPS instead of HTTP

HTTP/2 Improvements

  • HTTP/2 is binary, instead of textual.
  • It is fully multiplexed, sending multiple requests in parallel over a single TCP connection.
  • It uses header compression HPACK to reduce overhead.
  • It allows servers to “push” responses proactively into client caches instead of waiting for a new request for each resource
  • It uses the new ALPN extension which allows for faster-encrypted connections since the application protocol is determined during the initial connection.
  • It reduces additional round trip times (RTT), making your website load faster without any optimization.
  • Domain sharding and asset concatination is no longer needed with HTTP/2.
  • For more details about HTTP2 improvements
  • For more details about HTTP2
  • http working group link

1) Add Nginx latest repo

Add the below PPA to install Nginx latest version 1.9.9 on Ubuntu/LinuxMint/Debian & RHEL/CentOS systems but it’s not required for latest distributions.

[Add Nginx Repo to RHEL/CentOS systems & Install]

$ sudo nano /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

[Install Nginx]
$ sudo yum install nginx

[Add Nginx PPA to Ubuntu systems & Install]

$ echo "deb http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx" >> /etc/apt/sources.list
$ echo "deb-src http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx"  >> /etc/apt/sources.list
$ curl http://nginx.org/keys/nginx_signing.key | apt-key add -
$ sudo apt-get update
$ sudo apt-get install nginx

[Add Nginx PPA to Debian systems & Install]

$ echo "deb http://nginx.org/packages/mainline/debian/ `lsb_release -cs` nginx" >> /etc/apt/sources.list
$ echo "deb-src http://nginx.org/packages/mainline/debian/ `lsb_release -cs` nginx"  >> /etc/apt/sources.list
$ curl http://nginx.org/keys/nginx_signing.key | apt-key add -
$ sudo apt-get update
$ sudo apt-get install nginx

[Check Nginx version]

$ nginx -v
nginx version: nginx/1.9.9

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

2 Comments on “How to Enable HTTP/2.0 Support on Nginx Web Server”

  1. Nice, article.

    There’s one catch.

    The Centos 7 nginx repo is built against OpenSSL 1.0.1. This version of OpenSSL only supports NPN and not ALPN. This means the faster secure handshakes you mentioned aren’t supported. The only work around is to recompile nginx from source and build it against OpenSSL 1.0.2 (which does support ALPN). Unfortunately, compiling and updating from source creates it’s own hassles.

    Yes…you can go the centminmod route…but I haven’t tested this enough to know if it will break anything else.

    I wish Nginx provided a repo that statically links in OpenSSL 1.0.2. This would really be ideal.

    Also hoping Nginx adds http2 push.

Leave a Reply

Your email address will not be published. Required fields are marked *