Welcome! Log In Create A New Profile

Advanced

Re: Redis2_pass with <host>:<port> from $args fail [maxf3r]

agentzh
April 11, 2012 11:36PM
On Tue, Apr 10, 2012 at 1:32 PM, massimo ferrari
<massimo.ferrari@gmail.com>wrote:

> I'm trying to address several redis instances, dispatching it on a
> host:port basis (one single backend location)
>
> here part of my nginx.conf location
> ...
> location /redis_backend {
> internal;
> set_unescape_uri $verb $arg_verb;
> set_unescape_uri $key $arg_key;
> set_unescape_uri $r_host $arg_host;
> set_unescape_uri $r_port $arg_port;
> redis2_query $verb $key;
> redis2_pass $r_host:$r_port;
> }
>

The redis2_pass directive only supports values with variable interpolation
to be the name of an already defined upstream. For example:

upstream foo1 {
server 10.32.26.7:6379;
}

upstream foo2 {
server 10.32.26.7:6379;
}

http {
server {
location /foo {
set $n 2;
redis_pass "foo$n";
}
}
}

Your way will not work as expected.

If really you want truly dynamic redis backends (you do not want to
redefine them in nginx.conf or something like that), you can have a look at
the lua-resty-redis library which supports exactly what you want in your
example:

https://github.com/agentzh/lua-resty-redis

Best,
-agentzh
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Redis2_pass with <host>:<port> from $args fail [maxf3r]

massimo ferrari April 10, 2012 04:34PM

Re: Redis2_pass with <host>:<port> from $args fail [maxf3r]

agentzh April 11, 2012 11:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 242
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