Enabling SPDY for Nginx in Plesk on CentOS

Plesk 12 ships with nginx 1.6 which implements the SPDY module. SPDY is a networking protocol whose goal is to speed up the web. In tests performed by Google it was shown that there was a speed up of 27% - 60% in page load time over plain TCP (without SSL), and 39% - 55% over SSL.

As I'm always looking to improve the performance of my websites and those of my clients I thought I'd go ahead and implement it. I added modified my config to include the spdy directive:

listen 443 ssl spdy;

Unfortunately this threw an error “nginx: [emerg] the ‘spdy’ parameter requires ngxhttpspdy_module”. On researching the matter it turns out that although nginx 1.6 does support SPDY the complied version included with Plesk does not.

I found that you needed to recompile a new version of nginx including the SPDY option in order to get this to work. I thought this sounded a bit daunting at first but as it turned out it was actually straightforward. I followed the procedure outlined by Lukasz in the Plesk User Voice forum.

Disclaimer time! Please note that the following are the steps I took to get my server to work, by following the instructions below you do so at your own risk since your server set up may not be the same as mine. I thoroughly recommend that you backup your server in its entirety and read through the whole article before proceeding.

First of all I checked my existing build options:

ngnix -V

Then I downloaded and built the latest nginx version with support for SPDY (remember to replace *** YOUR BUILD OPTIONS HERE *** with your build options from the previous step):

cd

NGINX_VERSION=1.6.2
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
./configure *** YOUR BUILD OPTIONS HERE *** --with-http_spdy_module
make
sudo make install

The above threw the error “./configure: error: SSL modules require the OpenSSL library” which was a bit confusing since OpenSSL was installed. A bit of searching around and I found that I was missing the openssl-devel package. I ran the following:

yum install openssl-devel

Then I ran the following commands again:

cd

NGINX_VERSION=1.6.2
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
./configure *** YOUR BUILD OPTIONS HERE *** --with-http_spdy_module
make
sudo make install

Checking the nginx build options (nginx -V) showed that the SPDY module was now installed. All that was then needed was to modify my config files to include the spdy directive. I had created custom config files when I enabled TLS 1.2 for the server so I needed to modify three files:

/usr/local/psa/admin/conf/templates/custom/nginxWebmailPartial.php
/usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
/usr/local/psa/admin/conf/templates/custom/server/nginxVhosts.php

Finally, all that was left was to reconfigure the virtual hosts and reload nginx:

/usr/local/psa/admin/bin/httpdmng --reconfigure-all
nginx -s reload

I was able to verify the installation by installing a Chrome extension which displays a little icon in the address bar of the Chrome browser if SPDY is enabled. It's also interesting to see which other sites have the protocol enabled.

Hope this helps!


comments powered by Disqus