-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redis2_pass with <host>:<port> from $args fail #11
Comments
I'm terribly sorry for the delay! I don't know why I missed the email for this ticket :( ngx_redis2 only supports nginx variables pointing to upstream names that are already defined. For example:
and then we can have
That will work. But you cannot specify raw host names and port number in the nginx variable for redis2_pass. It seems that you're already using Lua to access ngx_redis2, so it is now recommended to use the lua-resty-redis library which is much more flexible and much easier to use than issuing subrequests to locations configured by ngx_redis2:
Also, this library is usually more efficient ;) Thanks! |
--location = /api { It seems this feature is not working any more with v0.11, the error.log always says: |
@signals2 There has been a test case for this usage in ngx_redis2's test suite that keeps passing for long: https://github.com/openresty/redis2-nginx-module/blob/master/t/sanity.t#L294 One common mistake is that you forget to define the named upstream {} blocks for all possible nginx variable values beforehand. |
Finally I find the answer, it's not working when using out of one or multiple if conditions, for example: instead the following config is working: maybe i'm using it in a wrong way? thanks |
@signals2 Please avoid the use of the "if" directive. See http://wiki.nginx.org/IfIsEvil Better use ngx_lua and lua-resty-redis for such things. |
@agentzh thanks alot |
I'm trying to address several redis instances, dispatching it on a host:port basis (one single backend location)
here 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;
}
...
I call /redis_backend location from a lua like this:
....
r_instance["redis_host"] = '127.0.0.1'
r_instance["redis_port"] = '33001'
....
local res = ngx.location.capture (
"/redis_backend",
{ args =
{ verb = r_verb,
key = redis_key,
host = r_instance["redis_host"],
port = r_instance["redis_port"],
}
}
)
...
in nginx error log (i use the openresty suite ngx_openresty/1.0.10.44), I got this error
2012/04/07 19:25:03 [error] 11715#0: *1 redis2: upstream "127.0.0.1:33001" not found, client: 127.0.0.1, server: ....
I'm sure redis instance is up&running. I'm able to connect to her via redis-cli or, simply setting redis2_pass 127.0.0.1:33001;
ciao
massimo
The text was updated successfully, but these errors were encountered: