So is "rewrite_by_lua" also evil?
agentzh
agentzh at gmail.com
Sat Oct 15 06:36:27 UTC 2011
On Sat, Oct 15, 2011 at 4:41 AM, Nginx User <nginx at nginxuser.net> wrote:
> Everything seems to be working fine. However, a small configuration
> error showed a potential problem in that the rewrite_by_lua directive
> does not seem to take account of the rewrite module's "last" flag.
>
> Contrived example:
>
> # GET /sometext/xyz.html
> server {
> ...
> location @pretty_urls {
> rewrite ^/sometext/xyz\.html$ /abc.html last;
>
> # line below included by mistake and shouldn't have been there
> # On the other hand, the hit above should mean it is not
> called anyway
> rewrite_by_lua 'ngx.exec("@proxy");';
> }
> location @proxy {
> include /etc/nginx/firewall.default;
> proxy_pass http://127.0.0.1:8080;
> ...
> }
> location ~ ^.+\.php$ {
> content_by_lua 'ngx.exec("@proxy");';
> }
> location / {
> try_files $uri $uri/ @pretty_urls;
> }
> }
> ... generates an error along the lines of ...
> 2011/10/14 20:10:26 [error] 17325#0: *16 lua handler aborted: runtime
> error: attempt to call a nil value, blah, blah, blah".
>
Interesting. But I cannot reproduce this issue with the following
small example on my side:
location @pretty {
rewrite ^/main/xyz\.html$ /abc.html last;
rewrite_by_lua 'ngx.exec("@proxy")';
}
location @proxy {
echo hello;
}
location /abc.html {
echo abc;
}
location /main {
try_files $uri $uri/ @pretty;
}
Then GET /main/xyz.html yields the output "abc" as expected and I
don't see that ngx_lua error message in my error.log.
Could you show me the error.log with --with-debug + debug log level?
Regards,
-agentzh
More information about the nginx
mailing list