So is "rewrite_by_lua" also evil?

Nginx User nginx at nginxuser.net
Wed Oct 12 21:34:41 UTC 2011


On 12 October 2011 21:35, Nginx User <nginx at nginxuser.net> wrote:
> This renders php as expected....
>
> if ($request_method !~* (GET|HEAD|POST) ) {
>        return 400;
> }
>
> ... while this sends php files as text downloads ...
>
> rewrite_by_lua '
>        method =  ngx.re.match(ngx.var.request_method, "GET", "i")
>        if method == nil then
>                method =  ngx.re.match(ngx.var.request_method, "POST", "i")
>                if method == nil then
>                        method =  ngx.re.match(ngx.var.request_method, "HEAD", "i")
>                        if method == nil then
>                                ngx.exit(ngx.HTTP_BAD_REQUEST)
>                        end
>                end
>        end
> ';
>
> See debug output: http://pastebin.com/A7LNeCf0

Some additional info.

I had thought the php files were being downloaded as text files but
this is not strictly true.  Files are downloaded whenever php is
called but they are always empty with a "0" status code.

The associated access log output for the request in the debug log in
the paste bin is: xx.xxx.xx.xx - - [12/Oct/2011:18:20:50 +0000] "GET
/help/ HTTP/1.1" 0 0 "http://testsite/index.php" "Mozilla/5.0
(Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.50.2 (KHTML, like
Gecko) Version/5.0.6 Safari/533.22.3"



More information about the nginx mailing list