Convert uWSGI HTTP server to work behind Nginx instead
<p>I'm serving my app with uWSGI using <code>uwsgi --http-socket 127.0.0.1:3031 -w app:app</code>, which works when I go to <code>127.0.0.1:3031</code> in a browser.  I want to use Nginx, so I told it to <code>uwsgi_pass</code> to that url, but now I get a 502 Bad Gateway error.  How do I put uWSGI behind Nginx?</p>

<pre class="lang-none prettyprint-override"><code>server {
    listen 8080;
    server_name 127.0.0.1;

    location / {
        uwsgi_pass 127.0.0.1:3031;
        include uwsgi_params;
    }

    location /static {
        alias /static/folder/location;
    }
}
</code></pre>

<pre class="lang-none prettyprint-override"><code>2016/05/16 19:50:09 [error] 6810#0: *4 upstream prematurely closed
connection while reading response header from upstream, client:
127.0.0.1, server: 127.0.0.1, request: "GET / HTTP/1.1", upstream: 
"uwsgi://127.0.0.1:3031", host: "127.0.0.1:8080"
</code></pre>