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.

How to Enable HTTP/2.0 Support on Apache Web Server

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

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...