To answer the question about placing the nginx server in front of another nginx: No, usually there is no good reason for this. This old tip comes from Apache, especially when mod_python was used with MPM Apache prefork. In this installation, each instance of Django started as a separate process, inside the mod_python / Apache container, and this would use a lot of RAM. The idea was to keep Apache's static file service by putting a lightweight event-driven HTTP server like nginx in front of Apache's heavy processes. This saves memory and increases productivity. Using a lightweight server like nginx for all requests is not a problem.
nginx has good URL rewriting handling, take a look at the Rewrite module.
Your question does not indicate what load (connections / second) you expect, or why you want to use nginx in the first place. If this is for a blog on a VPS server or similar low-load setup, look at using Apache with mod_wsgi in daemon mode. This has performance and RAM usage very close to FastCGI, and mod_wsgi has recently become the officially recommended way to host Django, see http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/
In general, I would suggest using Apache / mod_wsgi, if possible, this is a stable and flexible combination. Make sure you don’t “prematurely optimize” using nginx, where Apache + mod_wsgi will work fine. For an overview of mod_wsgi's performance in daemon mode, see: http://code.google.com/p/modwsgi/wiki/PerformanceEstimates
nginx is awesome, but for Django's solution, nginx is IMHO better suited for load balancing for many Apache instances or for a standalone server for static files. Both of these usage scenarios make sense only for large loads.
Jesper Mortensen
source share