http upstream keepalives

Francis Daly francis at
Mon May 14 18:57:00 UTC 2012

On Mon, May 14, 2012 at 07:32:18PM +0200, Davide D'Amico wrote:

Hi there,

> Hi, I'm reading here: 
> so I've tried:
> server {

>   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 "";

That proxy_set_header directive means that any at an enclosing scope
are not relevant in this location{}.

>     proxy_pass;
>   }
> }
> On I launched:
> > nc -4 -l 2323
> And so I saw:
> GET / HTTP/1.1
> Host:
> User-Agent: Wget/1.12 (darwin10.5.0)
> Accept: */*
> As you can see the Host header is wrong so I tested this vhost:

No, the Host: header is what you configured it to be.

As your next example also shows.

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

The documentation you link to looks correct to me.

(As I read it, it says "Last-Modified: Mon, 23 Apr 2012 13:32:31 GMT".)

It includes "..." where you include specific directives. It turns out that
the specific directives you include don't do what you expected them to.

So: what documentation update could have avoided your confusion, or
adjusted your expectations to match what nginx actually does?

Note that this is unrelated to the "keepalive" directive; it is arguably
related to the proxy_set_header directive; but it is probably more
generally related to directive inheritance in nginx.

Some directives don't inherit at all -- so if you want it to apply in
a location{}, you must set it in that location.

Some directives do inherit from http > server > location -- so to see
whether it applies in a location{}, you may have to check enclosing
scopes too.

Some (few) directives are "paired", and will affect the inheritance of a
different directive -- so to see whether it applies in a location{}, you
have to check its partner directive too, possibly in enclosing scopes.

But for all(?) directives that do inherit, inheritance is by replacement,
not addition.

Where would you have looked to find notes like the above? Perhaps if a
suitable place can be identified, a corrected version could be put there.

Francis Daly        francis at

More information about the nginx mailing list