What is the best method deploying Python (including Django) behind Nginx?
2 Answers
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_pas
s in nginx)
-
-
No, nginx listens on our public IP and takes all requests. It passes django requests to apache and handles the static file itself. Nov 14, 2011 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.