keepalive to backend server without upstream

1,400 views
Skip to first unread message

Michael Rushanik

unread,
Mar 17, 2014, 9:15:54 AM3/17/14
to openre...@googlegroups.com
We need to  configure keepalive for http connections without upstream module, since  performs a custom routing using Lua script and actually not using it.
The question is it possible to configure keepalive without upstream module, using the reverse proxy only? 
Or might be somehow interact with upstream from Lua script?

This message may contain confidential and/or privileged information. 
If you are not the addressee or authorized to receive this on behalf of the addressee you must not use, copy, disclose or take action based on this message or any information herein. 
If you have received this message in error, please advise the sender immediately by reply email and delete this message. Thank you.

Yichun Zhang (agentzh)

unread,
Mar 17, 2014, 3:24:23 PM3/17/14
to openresty-en
Hello!

On Mon, Mar 17, 2014 at 6:15 AM, Michael Rushanik wrote:
> The question is it possible to configure keepalive without upstream module,
> using the reverse proxy only?

Note that the standard ngx_proxy module *is* an nginx upstream module.
I think you just mean that you are not using the "upstream" directive
to group your backend servers.

Well, to use the ngx_http_upstream_keepalive module to do connection
pooling for ngx_proxy, you have to use the "upstream" directive.

You can still use the "upstream" to define the host names you might
use like this:

upstream foo.com {
server foo.com;
keepalive 10;
}

upstream bar.com {
server bar.com;
keepalive 10;
}

as long as you can know the full list of domains you might use (or
just the hottest ones that need connection pooling most). That way,
when you do

set $target 'foo.com';
proxy_pass $target;

The ngx_proxy module will pick up your upstream foo.com {} first and
no dynamic domain name resolving is needed at all.

Regards,
-agentzh

Michael Rushanik

unread,
Mar 18, 2014, 4:28:33 AM3/18/14
to openre...@googlegroups.com
Hello Yichun,
You're right in clarifications, I mean "upstream" directive. Thanks for suggestion, I'll try it.
In terms of dynamic management the list of upstream's I understand that no way except to update configuration and restart Nginx... is it correct?
-- 
Sincerely,
Michael Rushanik

Yichun Zhang (agentzh)

unread,
Mar 18, 2014, 2:53:17 PM3/18/14
to openresty-en
Hello!


On Tue, Mar 18, 2014 at 1:28 AM, Michael Rushanik wrote:
> In terms of dynamic management the list of upstream's I understand that no
> way except to update configuration and restart Nginx... is it correct?

There is no official way of dynamically changing the list of upstream blocks. Though there is an ongoing work in my ngx_lua-upstream module:


For more flexible proxying, you're recommended to build upon the ngx_lua's cosocket API. James Hurst's lua-resty-http library is such an example:


The cosocket API supports connection pools upon dynamic domains out of the box.

Regards,
-agentzh

Michael Rushanik

unread,
Mar 23, 2014, 7:55:16 AM3/23/14
to openre...@googlegroups.com
Hello Yichun,
Both of these modules looks like still not production ready.
Anyway, currently we suspend our research in this way.
But thanks a lot for response and clarification.
-- 
Sincerely,
Michael Rushanik
Reply all
Reply to author
Forward
0 new messages