nginx-eval-module icon indicating copy to clipboard operation
nginx-eval-module copied to clipboard

Use eval with redis2?

Open mcorner opened this issue 15 years ago • 3 comments

I am trying to use eval with the redis2 nginx plugin. I want to get the backend server name from redis.

I am trying with this:

location / {

eval_escalate on;

eval $answer { redis2_raw_query 'get server_name\r\n'; eval_override_content_type text/plain;

redis2_query get server_name;

redis2_pass 127.0.0.1:6379; } proxy_pass $answer;

But that doesn't work because the redis response has the string length at the beginning of the response. So you get:

2010/12/28 17:05:34 [error] 52979#0: *73 invalid URL prefix in "$24 http://127.0.0.1/foo//" while sending to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

Any ideas?

mcorner avatar Dec 28 '10 22:12 mcorner

You better talk to the author of redis2 module.

vkholodkov avatar Dec 29 '10 13:12 vkholodkov

@mcorner have you been able to make it work with Redis2?

jnbdz avatar May 15 '13 08:05 jnbdz

I was able to make it work with http://wiki.nginx.org/HttpRedis

Here is my config:

location = /session { eval_escalate on; eval $session { set $redis_key $cookie_session; redis_pass [...]:6379; }

echo $session; }

jnbdz avatar May 17 '13 01:05 jnbdz