title: Why does nginx proxy_pass close my connection?
body: <p>The documentation says the following</p>
  
  <blockquote>
    <p>Sets the HTTP protocol version for proxying. By default, version 1.0 is used. Version 1.1 is recommended for use with keepalive connections and NTLM authentication. </p>
  </blockquote>
  
  <p>In my nginx config I have</p>
  
  <pre><code>    location / {
          proxy_http_version 1.1;
          proxy_pass http://127.0.0.1:1980;
      }
  </code></pre>
  
  <p>Doing <a href="http://127.0.0.1:1980" rel="noreferrer">http://127.0.0.1:1980</a> directly I can see my app get many request (when I refresh) on one connection. This is the response I send</p>
  
  <blockquote>
    <p>HTTP/1.1 200 OK\nContent-Type:text/html\nContent-Length: 14\nConnection: keep-alive\n\nHello World!  </p>
  </blockquote>
  
  <p>However nginx makes one request and closes it. WTH? I can see nginx sends the "Connection: keep-alive" header. I can see it added the server and date header. I tried adding <code>proxy_set_header Connection "keep-alive";</code> but that didn't help.</p>
  
  <p>How do I get nginx to not close the connection every thread?</p>