Welcome! Log In Create A New Profile

Advanced

Re: Lua/Redis Routing with Failover

Brian Akins
February 01, 2012 09:58PM
You can't really change the upstream list on the fly. However you
could do something like this (psuedo code)

location / {
set $backend "default.backend.server";

rewrite_by_lua '
res = ngx.location.capture("/redis", { method = ngx.HTTP_PUT, body =
"srandmember setwithbackends\r\n" }
-- parse res.body to get the value
ngx.var.backend = backend_that_I_parsed
'
proxy_pass $backend$uri;

}

from http://wiki.nginx.org/HttpRedis2Module#Lua_Interoperability
location /redis {
internal;
redis2_raw_query $echo_request_body;
redis2_pass 127.0.0.1:6379;
}

If redis set has hostnames in it, you'll need to have resolver
enabled. If you wanted, you could wrap the proxy_pass in a capture
and try the list in order until you got a good response.

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Lua/Redis Routing with Failover

rovar 1977 January 31, 2012 10:28PM

Re: Lua/Redis Routing with Failover

agentzh 567 January 31, 2012 11:26PM

Re: Lua/Redis Routing with Failover

rovar 586 February 01, 2012 11:06AM

Re: Lua/Redis Routing with Failover

rovar 537 February 01, 2012 12:04PM

Re: Lua/Redis Routing with Failover

Brian Akins 579 February 01, 2012 09:58PM

Re: Lua/Redis Routing with Failover

agentzh 508 February 01, 2012 11:22PM

Re: Lua/Redis Routing with Failover

rovar 721 February 01, 2012 11:42PM

Re: Lua/Redis Routing with Failover

agentzh 625 February 02, 2012 03:52AM

Re: Lua/Redis Routing with Failover

rovar 922 February 02, 2012 07:40AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 212
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready