So is "rewrite_by_lua" also evil?

Eugaia ngx.eugaia at
Sat Oct 15 10:16:31 UTC 2011

On 15/10/2011 12:40, agentzh wrote:
> Okay, I must say that ngx_rewrite's "last" won't affect rewrite_by_lua
> because rewrite_by_lua is not part of that module (and there's no
> known way to achieve that).
You could achieve that now by creating a dummy variable, and instead of 
using a new handler for the rewrite by code, you wrap the code around 
the setby lua code.  It would waste a few cycles, since it would be 
setting a variable unnecessarily, but would have the benefit of not 
slowing down the execution of code that didn't use rewrite_by, since it 
wouldn't be adding an extra handler to process for all the other requests.

A better way would be to extend the NDK and expose a generic 
rewrite-phase, script engine interface that other scripting functions 
(that are more than just set_xxx) can use, and to use that instead.  
You'd then not be wasting cycles on setting a variable unnecessarily.  
It'd be mostly similar to the set_var stuff, but would need to take the 
normal 'code'-type functions rather than the NDK setvar function types.



More information about the nginx mailing list