Setup a http/2.0 web server via nginx

nginx now supports http/2.0
My blog is now http2.0 enabled!

nginx supports http/2.0 since version 1.9.5, if you have your own ssl cert for your own domain, you can now easily setup a http/2.0 enabled web server via nginx!

I’ll use Ubuntu 14.04 LTS as an example here, and assume you already have a https enabled site via old versions of nginx.

Add nginx mainline repository from nginx.org:

Add PGP key for apt:

Update apt repository local cache:

Remove old nginx(remember to backup your configs!):

Now install the latest version of nginx:

Make sure that you are now using ningx v1.9.5 or newer version that supports http/2.0

(–with-http_v2_module)

The critical part – http/2.0 config, you should configure your https server as usual, make sure everything is okay, then open your config again, find the part listening config:

server {
# SSL configuration
#
listen 443 ssl ;
listen [::]:443 ssl ipv6only=on;
.
.
.

}

Add the keyword “http2” behind “ssl” like this:

server {
# SSL configuration
#
listen 443 ssl http2;
listen [::]:443 ssl http2 ipv6only=on;
.
.
.

}

Restart nginx service:

If there is no any error message/log, then you should now have a http/2.0 enable web server!

You can use the “HTTP/2 and SPDY indicator”(for Firefox, for Chrome) browser extension to help you detect if http/2.0 is now enable!

Example, take a look at the right side of the site url:
http2_blog_resized

If you are using a chrome/chromium based browser, this links can also help you confirm the http/2.0 connections:
chrome://net-internals/#http2
http2_chromium

發表迴響