Batista R. Harahap

Compiling nginx 1.4.0 With SPDY on CentOS 6

Just a few days ago, the latest version of nginx at 1.4.0 was released to the public. The version bump adds a lot of new capabilities for your web stack. The most interesting for me was support for SPDY 2 protocol.

Excerpts from Chromium SPDY's page reads below:

As part of the "Let's make the web faster" initiative, we are experimenting with alternative protocols to help reduce the latency of web pages. One of these experiments is SPDY (pronounced "SPeeDY"), an application-layer protocol for transporting content over the web, designed specifically for minimal latency.  In addition to a specification of the protocol, we have developed a SPDY-enabled Google Chrome browser and open-source web server. In lab tests, we have compared the performance of these applications over HTTP and SPDY, and have observed up to 64% reductions in page load times in SPDY. We hope to engage the open source community to contribute ideas, feedback, code, and test results, to make SPDY the next-generation application protocol for a faster web.

In order for SPDY to work, one will need an SSL certificate and OpenSSL 1.0.1c at least to compile and run a website successfully with nginx. SPDY needs NPN enabled with OpenSSL and CentOS only provides 1.0.0. According to a blog post here, we can just add a repo to get OpenSSL to work nicely.

Here are the steps needed to compile nginx with SPDY support: $ rpm -ivh --nosignature http://rpm.axivo.com/redhat/axivo-release-6-1.noarch.rpm $ yum --enablerepo=axivo update openssl $ cd /opt/src $ wget http://nginx.org/download/nginx-1.4.0.tar.gz $ tar xfz nginx-1.4.0.tar.gz $ cd nginx-1.4.0 $ ./configure --with-pcre --with-http_ssl_module --with-http_spdy_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --prefix=/usr/local/nginx $ make -j4 $ make install

Now that the steps above are through, it's time enable SPDY with your websites assuming that you already have a working nginx configuration with SSL enabled. It's actually really simple, the full explanation is located at nginx's SPDY documentation.

server { listen 443 ssl spdy; ssl_certificate server.crt; ssl\_certificate\_key server.key; ... }

Now test your website at spdycheck.org to see if your SPDY implementation is successful. Cheers!

07 May 2013 by Batista Harahap on centos | compile | linux | nginx | spdy | Web
comments powered by Disqus