So is "rewrite_by_lua" also evil?

Nginx User nginx at
Sat Oct 15 09:57:29 UTC 2011

On 15 October 2011 12:40, agentzh <agentzh at> wrote:
> On Sat, Oct 15, 2011 at 4:46 PM, Nginx User <nginx at> wrote:
>> # GET /forum/
>> server {
>>  root /home/user/
>>  ...
>>  location @pretty_urls {
>>       # A number of rewrite rule. Hit line replicated
>>       ...
>>       rewrite ^/(abc|forum|xyz)/?$ "/index.php?pretty;action=$1" last;
> 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).
I guessed as much. I didn't need that line there in this case and if
neeed, "try_files /dummy/ @proxy" would do the job.
I like ngx_lua because it allows me to jump locations. Needs hacks to
do this with the rewrite module. Either the try_files hack above or
mapping an obscure error code to a location and using "return code".

All in all, I have come to realise that ngx_lua is slightly evil in
that unexpected things can happen. As with "if" however, evil
understood is evil avoided :-)

Any thoughts on Marcus' points earlier on clearing the ctx in the core?
Seems to suggest that may cause problems elsewhere and that it is
better to be handled at the module level.
Seems logical as whether it was originally an oversight or not,
changing it now would break other stuff.

More information about the nginx mailing list