On Fri, Mar 30, 2012 at 3:22 PM, Александр Решетников <saniek1@yandex.ru> wrote:
> Sorry that I write to you often. just do not know whether you have a blog,
> wrote would go there.
> Using "lua", instead "eval", it is convenient.
> But there is a mistake, which I think is a feature of the module.
>
> code nginx:
> set $res "0";
> rewrite_by_lua "
> local reply = ngx.location.capture ('/redisop?op=get&name
> ='..ngx.var.sessID);
> local parser = require 'redis.parser'
> local res = parser.parse_reply (reply.body)
> ngx.var.res = res
> ";
> set $old $res; / / returns 0, but echo $res returns normall value.
>
> What should I do, perhaps it's my fault again.
> Thanks for your help.
The problem here is that the rewrite_by_lua directive *always* runs
after all those "set" statements in the location block, even if you
write "rewrite_by_lua" before "set".
You can read my nginx tutorials on nginx directive running order:
http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-enuk.html#02-NginxDirectiveExecOrder01
Good luck!
-agentzh
P.S. I've cc'd the openresty mailing group so that other people can
see our discussion here ;)