title: How can I setup Nginx Proxy Buffering with Gunicorn over Amazon EC2?
body: <p>My Django app is hosted up on Amazon EC2. Gunicorn runs on the same machine and serves all the dynamic content that I have. There is no static content. I have TWO of these machines (both machines are running Ubuntu 11.04 on a micro instance. These are easy to scale horizontally) and I have a ELB (Elastic Load Balancer) sitting in front of both of these servers. </p>
  
  <p>For the sake of example, the external ip of both of these gunicorn/django ubuntu machines is:</p>
  
  <pre><code>12.34.567.12:8000 &amp; 21:43:765:21:8000 (gunicorn runs on port 8000). 
  </code></pre>
  
  <p>If I were to put either of these addresses into my browser, I can interact with my server and send/retrieve data.</p>
  
  <p>When I place an ELB infront of these two machines, the new address I can use to interact with BOTH DJANGO/GUNICORN SERVERS is: </p>
  
  <pre><code>dualstack.myloadbalancer-123456789.us-east-1.elb.amazonaws.com:8000
  </code></pre>
  
  <p>When I've been reading a lot of resources across the internet and many suggested having an NGINX box sitting in front the Django app servers behind the ELB to buffer requests for slow clients. I think this would be a good feature to have since I don't want to lose any requests. The diagram below will explain is more clearly:</p>
  
  <p><img src="https://i.stack.imgur.com/mjgmd.jpg" alt="enter image description here"></p>
  
  <p>Just like the diagram above, how can I configure the nginx box sitting in front of the django app/gunicorn servers to act as a reverse proxy so that it can buffer requests for slow clients? (this way, instead of timing out, it keeps the request without losing it)</p>