Help with Keepalive on NGINX

Nick Toseland nick at
Fri Jul 26 09:33:42 UTC 2013

Hi All,

I am struggling to get keepalives to work on Nginx, I believe I have 
added the necessary configuration. Can you take a look and suggest where 
I may be going wrong or what I am missing?

We have a nginx server that sits in front of a varnish server which sits 
in front of the back-end servers

http {

     keepalive_timeout  120;
     keepalive_requests 500;

     upstream varnish_rand {
         keepalive 256;

     server {

         location / {

             proxy_pass   http://varnish_rand;
             proxy_http_version 1.1;


You can see that the nginx server is using HTTP1.1 to communicate with 

*varnishtop -i RxProtocol *
list length 1

      9.67 RxProtocol     HTTP/1.1

However there nginx always send a "connection close"

*varnishtop -c -i RxHeader -I "Connection"*

list length 1

      9.59 RxHeader     Connection: close

Thanks in advance


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list