Question

What is the best way to serve a Django application over the SPDY [1] protocol?

[1] http://www.chromium.org/spdy

Was it helpful?

Solution 2

It works with nginx > 1.5.10 and Django run as fastcgi server.

Recent versions of Chrome and Firefox dropped support for SPDY v2. So you need at least SPDY3 support on the server side. Nginx versions higher than 1.5.10 support version 3 of the protocol.

Django Mainline Installation

Currently (as of Feb 2014) Nginx > 1.5.10 is only available from the mainline branch, not from stable. On most Linux distributions, it is easiest to install mainline packages provided by the nginx project.

Nginx and Django configuration

The Django documentation explains how to run Django with Nginx through fastcgi. The configuration that is provided there can be used as a starting point.

In addition, you need SSL certificates for your host and extend the Nginx configuration in the following ways:

  • The listen configuration options needs to be modified to: from listen 80; to listen 443 ssl spdy;.

  • You need to add basic ssl configuration options, most importantly a certificate and key.

So, both modifications combined, the configuration may look as follows:

server {
    listen       443 ssl spdy;
    server_name  yourhost.example.com;

    ssl_certificate      <yourhostscertificate>.pem;
    ssl_certificate_key  <yourhostskey>.key;
    ssl_prefer_server_ciphers   on;

    location / {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:8080;
    }
}

Then run your Django as in fastcgi mode, as follows:

python ./manage.py runfcgi host=127.0.0.1 port=8080

Testing your setup

  • Point your browser to https://yourhost.example.com
  • You should be able to verify that the connection is done via SPDY in:
    • Chrome: Look for an active SPDY session in chrome://net-internals/#spdy
    • Firefox: Check the Firebug Network tab and look for the X-Firefox-Spdy:"3.1" response header.

OTHER TIPS

One way is to run Django on Jython with Jetty - http://www.evonove.it/blog/en/2012/12/28/django-jetty-spdy-blazing-fast/

Also, apparently nginx has some draft module for SPDY

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top