So is "rewrite_by_lua" also evil?

Nginx User nginx at nginxuser.net
Thu Oct 13 04:30:13 UTC 2011


On 13 October 2011 04:34, agentzh <agentzh at gmail.com> wrote:
> The debug log data you've provided contains a lot of references to the
> location @pretty_urls which is missing from your original nginx.conf
> snippet. Could you please provide a minimized but complete nginx.conf
> that can reproduce this problem as well as the corresponding debug.log
> snippet?

server {
       ...
       location @pretty_urls {
               # some rewrite rules to php
       }
       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;
       }
}

If request ends in ".php" it is sent to @proxy by php location. If not
".php", Nginx tries to find and serve resource. If not found, sent to
@pretty_urls where it will either be rewritten to ".php" or a 404
error returned.



More information about the nginx mailing list