http upstream keepalives

Davide D'Amico davide.damico at contactlab.com
Mon May 14 17:32:18 UTC 2012


Hi, I'm reading here: 
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive

so I've tried:

server {
   keepalive_timeout    70;
   error_log /var/log/nginx/test-error.log;

   listen 80;
   server_name www.dave.it;
   proxy_read_timeout      3600;

   proxy_set_header        Host $host;
   proxy_set_header        X-Real-IP $remote_addr;
   proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;


   location / {
     proxy_http_version 1.1;
     proxy_set_header Connection "";
     proxy_pass http://172.16.7.9:2323;
   }
}

On 172.16.7.9 I launched:

 > nc -4 -l 172.16.7.9 2323

And so I saw:
GET / HTTP/1.1
Host: 172.16.7.9:2323
User-Agent: Wget/1.12 (darwin10.5.0)
Accept: */*


As you can see the Host header is wrong so I tested this vhost:
server {
   keepalive_timeout    70;
   error_log /var/log/nginx/test-error.log;

   listen 80;
   server_name www.dave.it;
   proxy_read_timeout      3600;

   proxy_set_header        Host $host;
   proxy_set_header        X-Real-IP $remote_addr;
   proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_http_version 1.1;
   proxy_set_header Connection "";

   location / {
     proxy_pass http://172.16.7.9:2323;
   }
}

And this time the backend answered as expected:

GET / HTTP/1.1
Host: www.dave.it
X-Real-IP: 172.16.7.249
X-Forwarded-For: 172.16.7.249
User-Agent: Wget/1.12 (darwin10.5.0)
Accept: */*


So I think that a little modification to documentation could be a good 
idea :)

Thanks,
d.




More information about the nginx mailing list