Using mod_spdy With Apache2 On Ubuntu 12.04

SPDY means is a new networking protocol whose goal is to speed up the web. It is Google’s alternative to the HTTP protocol and a candidate for HTTP/2.0. SPDY augments HTTP with several speed-related features such as stream multiplexing and header compression.This tutorial explains how to use mod_spdy with Apache2 on Ubuntu 12.04.

1 Preliminary Note

SPDY runs over HTTPS, so we need an HTTPS-enabled web site to test SPDY. Please note that SPDY will fall back to HTTPS if the user’s browser does not support SPDY or if things go wrong, so installing mod_spdy doesn’t hurt your existing setup.

assuming that you have a working LAMP setup, as described on Installing Apache2 With PHP5 And MySQL Support On Ubuntu 12.04 LTS (LAMP)

testing purposes I wil lsimply enable the default SSL web site that comes with Ubuntu’s Apache package

enable SSL, just run

a2enmod ssl

enable the default SSL web site, run

a2ensite default-ssl

Restart Apache afterwards

/etc/init.d/apache2

restart

2 Installing mod_spdy

Google provides Debian/Ubuntu packages for mod_spdy on https://developers.google.com/speed/spdy/mod_spdy/.

cd /tmp
wget https://dl-ssl.google.com/dl/linux/direct/mod-spdy-beta_current_amd64.deb

cd /tmp
wget https://dl-ssl.google.com/dl/linux/direct/mod-spdy-beta_current_i386.deb

… and install it as follows:

dpkg -i mod-spdy-*.deb
apt-get -f install

(This will also add the Google mod_spdy repository to the apt sources so that the module will be kept up-to-date:

cat /etc/apt/sources.list.d/mod-spdy.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb http://dl.google.com/linux/mod-spdy/deb/ stable main

Restart Apache afterwards:

/etc/init.d/apache2

restart

mod_spdy needs no configuration, it works out of the box

cat /etc/apache2/mods-available/spdy.conf
<IfModule spdy_module>
    # Turn on mod_spdy. To completely disable mod_spdy, you can set
    # this to "off".
    SpdyEnabled on

    # In order to support concurrent multiplexing of requests over a
    # single connection, mod_spdy maintains its own thread pool in
    # each Apache child process for processing requests.  The default
    # size of this thread pool is very conservative; you can override
    # it with a larger value (as below) to increase concurrency, at
    # the possible cost of increased memory usage.
    #
    #SpdyMaxThreadsPerProcess 30

    # Memory usage can also be affected by the maximum number of
    # simultaneously open SPDY streams permitted for each client
    # connection.  Ideally, this limit should be set as high as
    # possible, but you can tweak it as necessary to limit memory
    # consumption.
    #
    #SpdyMaxStreamsPerConnection 100
</IfModule>

3 Testing

test if SPDY is working. We need a browser with SPDY support. e.g. Google Chrome. Open Chrome and reload your SSL web site (e.g. https://www.example.com) – it is important that you reload it so that it can use SPDY (the first time you loaded it in chapter 1 it used normal HTTPS). Afterwards, open a new tab and type in the URL

chrome://net-internals/#spdy