0

What is the best method deploying Python (including Django) behind Nginx?

2
  • Define "best"... – Ignacio Vazquez-Abrams Nov 13 '11 at 23:00
  • I would say "with the package manager of your distribution" – mailq Nov 14 '11 at 1:00
2

The official django documentation says that apache and mod_wsgi is the recommended way to get django into production.

We use nginx to proxy through to apache running mod_wsgi to serve our django site. We have apache listening on 127.0.0.1 and use proxy_pass to pass requests to Apache. The nginx wiki has a bunch of examples.

I've also heard good things about gunicorn. (and you would still use proxy_pass in nginx)

2
  • Did you mean pass the requests to nginx instead of Apache? – user965363 Nov 14 '11 at 1:42
  • No, nginx listens on our public IP and takes all requests. It passes django requests to apache and handles the static file itself. – tfitzgerald Nov 14 '11 at 4:23
0

I use FastCGI for this on one of my sites (it's built on Django), both nginx and Django can do FastCGI natively. Addition: I have stress tested various approaches: nginx w/FastCGI, nginx w/Apache and then FastCGI, nginx w/Apache and then mod_wsgi and even nginx w/Apache and then mod_python. Performance was pretty much the same for a real application, so I chose nginx w/FastCGI without Apache to save RAM a bit.

Not the answer you're looking for? Browse other questions tagged or ask your own question.