So is "rewrite_by_lua" also evil?
agentzh at gmail.com
Thu Oct 13 04:55:20 UTC 2011
On Thu, Oct 13, 2011 at 12:32 PM, Nginx User <nginx at nginxuser.net> wrote:
> On 13 October 2011 05:06, agentzh <agentzh at gmail.com> wrote:
>> Basically, calling ngx.exec to jump to a named location is buggy in
>> that ngx_http_named_location() in the nginx core does not clear module
>> ctx structures as ngx_http_internal_redirect() so ngx_lua should have
>> cleared its ctx itself.
> I see. Don't know much about this but does this mean the httpRewrite
> module does clear this ctx? I.E. why doesn't this affect the standard
> rewrite module?
For ngx_lua, for example, it does have a flag field named
"entered_content_phase" in its context object (ctx) which marks
whether the current request has entered the content phase. So when
doing an internal redirection to a named location, this field must be
cleared out or some bad things will happen in rewrite_by_lua because
ngx_lua now believes it's in a content_by_lua not rewrite_by_lua.
Well, there're more flags like this in ngx_lua ctx. For ngx_rewrite,
it's probably safe just because of its simplicity.
Well, I still believe it is a bug in ngx_http_named_location function
in the nginx core. The thumb of rule is to avoid using named locations
like @proxy but use normal locations configured with the "internal"
directive. And we've been keeping doing this in our production apps.
More information about the nginx