Most webmaster and sysadmins has upgraded their setup to Ubuntu 16.04 LTS now. But Not all has upgraded, some of them wants HTTP/2 on Ubuntu 14.04 LTS. Here Are Steps For Upgrading Ubuntu 14.04 to Latest Nginx to Support HTTP2 With Troubleshooting Error. Removal of current Nginx not needed.. Nginx Has No Support For this Upgrade. This is not recommended, we can not give whether HTTP/2 will work or not. But this upgrade is on live website without any downtime and avoid white page error while forcing upgrade. We are forcing the upgrade, it is not normal upgrade.
Steps Before Upgrading Ubuntu 14.04 to Latest Nginx to Support HTTP2 : Changes on Config Files
You must take backup of /etc/nginx/nginx.conf
and /etc/nginx/sites-enabled/default
or /etc/nginx/sites-enabled/
directory (depends on how many vHosts you have, name of the files). You can copy-paste the files as secret gist on GitHub gist for easy work. First, you need some changes on /etc/nginx/sites-enabled/default
. Normally we use something like –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | server { listen 443 ssl spdy default; listen [::]:443 ssl spdy default; root /path/to/webroot; index index.php index.html; server_name thecustomizewindows.com www.thecustomizewindows.com; error_log /var/log/nginx/error.log; location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } |
You need to change include fastcgi_params
to include fastcgi.conf
, change listen 443 ssl spy default
to listen 443 ssl http2 default_server
, remove any SPDY related directives like add header for NPN, SPDY compression etc. HTTP/2 has a big blacklist of old and insecure ciphers, so we must avoid them. You should have –
---
1 | ssl_prefer_server_ciphers on;. |
Do the changes and save that file.
/etc/nginx/nginx.conf
needs uncomments these directives –
1 2 | limit_zone slimits $binary_remote_addr 5m; limit_conn slimits 5; |
Make sure that limit_req_zone
looks like this –
1 | limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; |
Also, change the fastcgi cache path. Save the files.
Steps Before Upgrading Ubuntu 14.04 to Latest Nginx to Support HTTP2 : Changes on Repository Information
cd
to /etc/apt/sources.list.d/
and do ls
to see if any nginx.list
present. If present simply delete with rm
command. Now edit the /etc/apt/sources.list
file to add :
1 2 | deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx |
Save it. Thereafter wget
wget nginx_signing.key
as written here –
So, you’ll run :
1 2 3 | cd ~ wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key |
You’ll get OK response. Run –
1 | sudo apt-get update && sudo apt-get upgrade |
There will be no change on version of Nginx.
Upgrading Ubuntu 14.04 to Latest Nginx to Support HTTP2
Above steps deliberately done as we switching to Nginx’s repo. Now run –
1 | add-apt-repository ppa:nginx/development |
You’ll get a whooping big response :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | This PPA contains the latest 'Mainline' Release version of the nginx web server software. (Formerly known as the "Development Version" of nginx) The following releases of Ubuntu (including in-development releases) are supported in this PPA: * Precise (12.04) * Trusty (14.04) * Xenial (16.04) * Yakkety (16.10) The following releases of Ubuntu will soon become End of Life, and therefore will receive no more updates beyond 1.11.2: * Wily (15.10) The following releases of Ubuntu are no longer supported, and have had their packages removed from the PPA: * Lucid (10.04) * Maverick (10.10) * Natty (11.04) * Oneiric (11.10) * Quantal (11.10) * Raring (13.04) * Saucy (13.10) * Utopic (14.10) More info: https://launchpad.net/~nginx/+archive/ubuntu/development Press [ENTER] to continue or ctrl-c to cancel adding it |
You will get prompts like :
1 2 3 4 | Configuration file '/etc/nginx/nginx.conf' ==> Modified (by you or by a script) since installation. ==> Package distributor has shipped an updated version. What would you like to do about it ? Your options are: |
After all completed run :
1 | sudo apt-get update && sudo apt-get upgrade |
Then replace /etc/nginx/nginx.conf
and /etc/nginx/sites-enabled/default
with our modified files as written in under Changes on Config Files subheader. Run nginx -t
and reboot the server on successful output. After making sure that your website is running, run nginx -V
and nginx -v
to check the output. You should have ngx_http_v2_module
and version will be like nginx/1.11.3
or above.
Now, test with some browser tool or third part web based tool. Browse your website’s non-cached pages to make sure that visitors are not getting white pages.
You Broken My Server. Give My Old Ngix Back!
Do the opposite changes on Repository Information, remove PPAs by deleting the .list files from /etc/apt/sources.list.d
directory and two lines we which we added to /etc/apt/sources.list
file. Also run :
1 | sudo add-apt-repository --remove ppa:nginx/development |
This won’t uninstall packages but the official repositories. You will fully remove the nginx, reboot, then run normal command to install nginx-extras, use the backup of backup of /etc/nginx/nginx.conf
and /etc/nginx/sites-enabled/default
. It is difficult because the repo of Official Ubuntu and Nginx are different. apt-get downgrade
does not exist but near similar way actually exists.