I've been doing a lot of research into back-end architecture. I'm currently running a django app server and a postgresql database server on Amazon's Web Services. All of my content is served through Gunicorn. I would like to know why nginx servers are place in front of the the django app servers. What is their purpose? Here is a diagram:


2 Answers 2


In many stacks, nginx is often placed in front of unicorn or gunicorn for buffering responses to slow clients.

See the nginx documentation for more information:


The ELB doesn't do buffering, so having nginx in place can save your bacon.


Generally you put a reverse proxy in front of backend servers like gunicorn (or tomcat in the java world) because they have more features and are more resilient.

E.g., with nginx you can add fine-grained access control, terminate SSL, and not be as susceptible to DOS attacks (which is what gunicorn specifically mentions in their docs ( http://docs.gunicorn.org/en/latest/deploy.html ).

In EC2 you could replace nginx and haproxy with an ELB if there are no special features of nginx or haproxy you are using. See http://harish11g.blogspot.com/2012/11/amazon-elb-vs-haproxy-ec2-analysis.html for a comparison of ELBs and haproxy.

  • I've look into back end setups of many other companies on AWS and some of them have the ELB in front and then NGINX behind them, why is that?
    – deadlock
    Commented Apr 16, 2013 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .