Setting Keepalive_timeout for specific location

Hi I’d like to know if setting keepalive for a specific location is
possible. Right now I have only managed to get it working on server {}
directive but not location {} directive.

Thanks,
Kim Y.

On Thu, Jul 18, 2013 at 5:06 PM, Kim Y. [email protected] wrote:

Hi I’d like to know if setting keepalive for a specific location is
possible. Right now I have only managed to get it working on server {}
directive but not location {} directive.

it seems possible according to the docs.
http://wiki.nginx.org/HttpCoreModule#keepalive_timeout indicates that
you can use the directive in a location as well.

What version of nginx is this, and what behaviour are you seeing?

-jf


He who settles on the idea of the intelligent man as a static entity
only shows himself to be a fool.

“Every nonfree program has a lord, a master –
and if you use the program, he is your master.”
–Richard Stallman

So says the documentation. But I have yet to see any working config
using
location directive.
I’m using a fairly old 1.0.15-2 off epel. No joy. wouldn’t want to
upgrade
my webclusters… that could open other cans of worms.

On Thu, Jul 18, 2013 at 5:28 PM, Kim Y. [email protected] wrote:

So says the documentation.

yup. I would dig into the source… but I think the wiki should be
accurate. For the most recent version of nginx, of course! (which is
why I asked about your version) I wouldnt be surprised if the older
versions dont have the directive at the location level. Only certain
directives were available at that level iirc.

But I have yet to see any working config using
location directive.
I’m using a fairly old 1.0.15-2 off epel. No joy. wouldn’t want to upgrade
my webclusters… that could open other cans of worms.

eh… no kidding? IF you really, really have to stick to that version,
perhaps a chain of nginxes might work.

-jf

Well it went through configtest. and that turned out okay. upgrading
nginx
would require me to run through the QA gauntlet. Just as equally
unpleasant.

Hello!

On Thu, Jul 18, 2013 at 05:06:26PM +0800, Kim Y. wrote:

Hi I’d like to know if setting keepalive for a specific location is
possible. Right now I have only managed to get it working on server {}
directive but not location {} directive.

Yes, it’s possible, and works fine on all versions I know. Test
config:

location / {
    keepalive_timeout 5;
    return 204;
}
location /short {
    keepalive_timeout 1;
    return 204;
}

Simple test which shows it actually works as expected:

$ time telnet 127.0.0.1 8080
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
GET / HTTP/1.1
Host: x

HTTP/1.1 204 No Content
Server: nginx/1.5.3
Date: Thu, 18 Jul 2013 10:11:18 GMT
Connection: keep-alive

Connection closed by foreign host.
5.45 real 0.00 user 0.00 sys

$ time telnet 127.0.0.1 8080
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
GET /short HTTP/1.1
Host: x

HTTP/1.1 204 No Content
Server: nginx/1.5.3
Date: Thu, 18 Jul 2013 10:12:10 GMT
Connection: keep-alive

Connection closed by foreign host.
1.50 real 0.00 user 0.00 sys

If it doesn’t work for you - you probably did something wrong.


Maxim D.
http://nginx.org/en/donation.html

Okay seems like location works for 1.2.x. Now I have another battle to
fight :expressionless: