Hello!
On Sat, Mar 22, 2014 at 12:03 AM, Makailol Charls wrote:
> Would it be possible to use rewrite_by_lua twice?
> For example, I have used rewrite_by_lua in server context for some common
> logic which will be inherited in each location block and now I want to write
> some additional code for specific location (code to jump on named based
> locations conditionally). Would this be possible or it will execute only
> rewrite_by_lua which is in that location block (and won't execute the common
> code which is written in server context.) ?
>
Yes, rewrite_by_lua in the inner scope will override the one in the
outer scope completely :) So in your case, the following should work:
rewrite_by_lua ' ngx.exec("@proxyA"); ';
location @proxyA {
rewrite_by_lua return;
proxy_pass http://someIP;
more_set_headers 'Foo: bar';
}
Eventually we'll make rewrite_by_lua used in the server {} block run
in the "server rewrite" phase and it will not get inherited by
locations, just like the standard "rewrite" directive.
Regards,
-agentzh