Steps to Upgrade Nginx for HTTP/2 Support (Ubuntu, Cloud Server)

Advertisement

We are taking it granted that who is reading this guide followed the steps like described in our guide for the setup of Nginx WordPress installation and website is already HSTS. Here the Steps to Upgrade Nginx for HTTP/2 Support on Cloud Server Running Ubuntu OS from Nginx with SPDY. We DO NOT recommend this upgrade on production website at time of publication of this article (4th April, 2016). Still, we are taking it as a working development site which needs some backup.

Understanding Difference in Repo & Versions For Nginx for HTTP/2 Support on Ubuntu

Normally we suggest to use apt-get install nginx-extras command to install Nginx Community Version from Debian Repo. nginx-extras has all the needed modules including cache purge module. As nginx-extras is intended for the advanced users, nginx-extras at this moment has no support for HTTP/2. It supports SPDY.

For Nginx with HTTP/2 on Ubuntu 14.04 KTS, we can use the ppa:nginx/development repository, which is clone of the Nginx MAINLINE branch. From this MAINLINE, Nginx Plus is developed.

Advertisement

---

Steps to Upgrade Nginx for HTTP/2 Support (Ubuntu)

So, you need to remove that old apt version of Nginx. It is obviously, you need to take backup of you minimum two settings files for an active website. One is that ../../sites-available/default and another is /etc/nginx/nginx.conf. We are assuming that, the user not exactly an advanced user. Any of the command below will work for the purpose i.e. upgrade Nginx for HTTP/2 support :

Vim

1

2

cat/etc/nginx/nginx.conf>~/nginx.conf

cp/etc/nginx/nginx.conf>~/nginx.conf

In the same way, take backup of another file. Then check by opening the backup with any text editor. Then proceed to remove Nginx and Install the desired one

Vim

1

2

3

4

5

6

7

sudo apt-get remove nginx*

sudo apt-get purge nginx*

rm-rf/etc/nginx

sudo add-apt-repository ppa:nginx/development

sudo apt-get update

sudo apt-get install nginx

sudo service nginx restart

This is an example basic configuration :

Vim

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

server{

listen443ssl http2;

server_name thecustomizewindows.com;

root/usr/share/nginx/html;

ssl on;

ssl_certificate/etc/ssl/example/example.crt;

ssl_certificate_key/etc/ssl/example/example.key;

ssl_protocols TLSv1 TLSv1.1TLSv1.2;

#ssl_ciphers;

#ssl_prefer_server_ciphers on;

ssl_session_cache shared:SSL:10m;

ssl_session_timeout24h;

keepalive_timeout300;

location/{

try_files$uri$uri/=404;

}

}

In nginx.conf file, the directives will differ :

Vim

1

2

3

4

5

http2_chunk_size8k;

http2_idle_timeout3m;

http2_max_concurrent_streams128;

http2_max_field_size4k;

http2_max_header_size16k;

Nginx has guides :

Vim

1

http://nginx.org/en/docs/http/ngx_http_v2_module.html

As a normal webmaster does not have 2-3 dedicated software engineers for bug checking and other matters, at this moment, we actually do not suggest this upgrade for production site. Other way is to use Nginx Plus. After paying $1700 per annum for Nginx Plus, obviously there will be custom support. Cloud Flare or other bigger websites has dedicated team to manage the software development part. SPDY is enough at this moment for production sites.