So is "rewrite_by_lua" also evil?

Nginx User nginx at nginxuser.net
Fri Oct 14 20:41:19 UTC 2011


Additional feedback to agentzh:

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".

As said, it was a misconfig but I would have expected that with the
earlier hit with the rewrite module, all further rewrites, including
ngx_lua's should stop.

Cheers



More information about the nginx mailing list