Alcides Fonseca

40.197958, -8.408312

nginx + passenger + django

I am currently in the process of migrating all the websites I have running on this VPS from apache2 to nginx. The Apache2+passenger bundle was working really fine, except for some unknown slowness with redmine, but I wanted to try another httpd and I’ve heard a lot of nginx, and passenger guys added support for it a while ago.

Since nginx doesn’t support loadable modules, I had to compile it with all the modules I might need in a near future, so the following instructions also include the http_push_module.

When testing this wiki in the nginx server, it was always serving the homepage for whatever URL I asked for. After two sessions digging into the nginx, passenger and django internals, and doing a few tests, I found out the problem:

Nginx provides Passenger a REQUEST_URI instead of the PATH_INFO header that django processes to route the request. Since PEP 333 requires a PATH_INFO header, I had to correct the problem in one of the two other. I ended up fixing it Passenger, since it’s the one responsible for the WSGI interface.

So even if you had already installed passenger, just add those two lines , and it should support Django straight away.

1 while debugging, the tmp/restart.txt trick didn’t work for wsgi, so I used a sudo killall -9 python since it was the only python process running.