So is "rewrite_by_lua" also evil?

Eugaia ngx.eugaia at
Sat Oct 15 10:43:59 UTC 2011

On 15/10/2011 13:33, agentzh wrote:
> On Sat, Oct 15, 2011 at 6:16 PM, Eugaia<ngx.eugaia at>  wrote:
>> 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.
> I do not fully grok your approach but I'd ask first: will this
> approach allow subrequests, internal redirection, non-blocking sleep,
> and all the other fancy stuffs?
If you were just wrapping around set_var, then no.  It would only be 
able to handle non-reentrant code, just like setby.

In order to have reentrant code, it would need to have a generic layer 
that would be able to jump in/out of the script engine (and handle 
re-calling the script engine post subrequest etc).  The rewrite handler 
would also need to be re-written to handle re-entering the script engine.

The advantage of having a generic rewrite re-entrant layer, though, 
would be that set_var would also be able to accept subrequests etc 
(assuming you used that to base setby on).


More information about the nginx mailing list