Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

closed as not constructive by Ward, mailq, Scott Pack, Shane Madden, MDMarra Nov 14 '11 at 2:00

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

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
up vote 2 down vote accepted

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 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)

share|improve this answer
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

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.

share|improve this answer

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