Enable SPDY for Your Erlang Website
Google’s Strange Loop presentation Making the Web Faster inspired me to enable SPDY on one of my side projects Zin In Sushi. This simple sushi restaurant review site is build in Erlang using Basho’s Webmachine in combination with Erlydtl.
Below is a quick writeup of the steps needed.
Assumptions:
- Your Erlang powered website is running on port 3000 (Substitute this with your own magic value) on HTTP.
- You are running a recent version of Ubuntu (I’m running 12.04 LTS).
- Your domain is
www.example.org
.
The steps in summary:
- Reverse proxy setup with Apache 2
- SSL Setup with Apache 2
- Installation of
mod_spdy
$ sudo service apache restart
, and you’re done!
Reverse proxy setup with Apache 2
First install Apache 2 if not already present:
1
|
|
Enable the proxy_http
Apache module to get reverse proxy support:
1
|
|
Add a new site to Apache’s available-sites
1
|
|
And past in the following contents (and replace the domain name and ports if needed):
1 2 3 4 5 6 7 8 |
|
Enable the site by executing:
1
|
|
Next up; SSL support!
SSL Setup with Apache 2
Enable the ssl
Apache module to enable SSL:
1
|
|
SSL certificates are not free, so in this article we generate a self signed SSL certificate to keep moving:
1 2 |
|
Important! When generating the key, make sure the FQDN matches your domain name:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
After generating the required encryption keys, we re-edit the reverse_proxy
site:
1
|
|
And append the following configuration code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Important! We need to check if Apache is listening on port 443 (SSL) and virtualhost support is enabled for this. /etc/apache2/ports.conf
should have the following lines enabled:
1 2 3 4 |
|
Now we’re in a good shape to add SPDY support
Installation of mod_spdy
You need to fetch the latest mod_spdy
package from Google:
Check the architecture of your system by running uname -m
.
Install the package by running the following commands:
1 2 3 |
|
Le moment suprême
Restart Apache to power up the new configuration:
1
|
|
And browse to your website https://www.example.org
in Google Chrome.
To verify mod_spdy
is working, open chrome://net-internals/#spd
just after the first page load. Your server’s domain should be listed in the table under the SPDY sessions heading.gs