Enabling Keep-Alive

Patrick Chkoreff pc at fexl.com
Thu May 24 20:13:15 UTC 2018


Hi everyone, I'm brand new to nginx and maybe you can help me with a
problem I'm having.

I was formerly using "pound" as a front-end for my web servers, but I'm
switching to nginx because pound has some problems and isn't supported.
Problem is, switching to nginx has disabled "Keep-Alive".  Pound handled
it just fine.  I've searched around looking for answers, and all I found
was something about configuring ngx_http_core_module, which I don't know
how to do or even where it is.  Besides, the nginx docs I've seen said
that keep-alive is enabled by default.

So here's the problem, stripped down to its essentials.

I'm running a web server on my own local Linux machine, listening on
127.0.0.1 port 9351.  I have added this stanza to my /etc/nginx/nginx.conf:

server
  {
  listen 127.0.0.1:80;
  server_name whatever;
  location /
    {
    proxy_pass  http://127.0.0.1:9351;
    proxy_http_version 1.1;
    proxy_next_upstream error timeout invalid_header http_500 http_502
http_503 http_504;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }

Here's the problem.  Every time I refresh http://127.0.0.1, I get a
brand new process ID.  Clearly Keep-Alive is not working.

I know the problem is not MY server, because I can bypass nginx and
keep-alive works fine.  I do this by visiting http://127.0.0.1:9351
directly.  Every time I refresh, I get the same PID.

So, is there ANY way to instruct nginx to keep using the same connection
every time, instead of tearing down and reconnecting on every request?

Thank you very much in advance for any advice you can offer.


-- Patrick



More information about the nginx mailing list