Hello!
On Thu, Feb 13, 2014 at 7:45 PM, m.nasedkin wrote:
> on nginx conf:
> ...
> localtion / {
> access_by_lua '
> ngx.log(ngx.INFO, "Invoke access rule")
>
> ';
> root html;
> index index.html index.htm;
> }
If you request the path / directly, then the ngx_index module will
initiate an internal redirect from the path / to path /index.html. We
can see this if we print out the current request URI in your
access_by_lua:
ngx.log(ngx.INFO, "Invoke access rule: ", ngx.var.uri)
And we can see the following nginx log messages:
[info] 9983#0: *1 [lua] [string "access_by_lua"]:2: Invoke access
rule: /, ...
[info] 9983#0: *1 [lua] [string "access_by_lua"]:2: Invoke access
rule: /index.html, ...
Note the URI in these two messages are different.
As I've said in my previous mail in this thread, internal redirect
will re-match a location for the new URI (here the same location / is
matched for the internal redirect from / to /index.html), and the
rewrite/access/etc phases of the new location will run again (even
when the new location is the same as the previous location initiating
the internal redirect).
So this is the expected behavior and you should prepare for it. You
configure the ngx_index module and you enable this internal redirect
by intention.
Regards,
-agentzh