Forum: NGINX Setting Keepalive_timeout for specific location.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Kim Yong (Guest)
on 2013-07-18 11:07
(Received via mailing list)
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 Yong
7b488e1be2db29c8489d80d59818b17e?d=identicon&s=25 Jeffrey Lim (jfl)
on 2013-07-18 11:16
(Received via mailing list)
On Thu, Jul 18, 2013 at 5:06 PM, Kim Yong <limkimyong@gmail.com> 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
Kim Yong (Guest)
on 2013-07-18 11:29
(Received via mailing list)
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.
7b488e1be2db29c8489d80d59818b17e?d=identicon&s=25 Jeffrey Lim (jfl)
on 2013-07-18 11:35
(Received via mailing list)
On Thu, Jul 18, 2013 at 5:28 PM, Kim Yong <limkimyong@gmail.com> 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
Kim Yong (Guest)
on 2013-07-18 11:40
(Received via mailing list)
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.
Maxim Dounin (Guest)
on 2013-07-18 12:14
(Received via mailing list)
Hello!

On Thu, Jul 18, 2013 at 05:06:26PM +0800, Kim Yong 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 Dounin
http://nginx.org/en/donation.html
Kim Yong (Guest)
on 2013-07-18 12:15
(Received via mailing list)
Okay seems like location works for 1.2.x. Now I have another battle to
fight :|
This topic is locked and can not be replied to.