So is "rewrite_by_lua" also evil?

Nginx User nginx at nginxuser.net
Wed Oct 12 18:35:59 UTC 2011


Hi.

Updated Nginx to 1.0.8 and did my 3rd party modules as well and even
went for rc versions

nginx: nginx version: nginx/1.0.8
nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-51)
nginx: configure arguments: --user=nginx --group=nginx
--prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy
--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi
--pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx
--with-http_stub_status_module --with-http_perl_module --with-debug
--without-http_memcached_module --without-http_scgi_module
--without-http_split_clients_module --without-http_ssi_module
--without-http_upstream_ip_hash_module --without-http_uwsgi_module
--add-module=/usr/src/redhat/BUILD/nginx-1.0.8/nginx-upstream-fair
--add-module=/usr/src/redhat/BUILD/nginx-1.0.8/ngx_cache_purge-1.4
--add-module=/usr/src/redhat/BUILD/nginx-1.0.8/ngx-headers-more-0.16rc3-0
--add-module=/usr/src/redhat/BUILD/nginx-1.0.8/ngx-devel-kit-0.2.17-4
--add-module=/usr/src/redhat/BUILD/nginx-1.0.8/ngx-echo-module-0.37rc5-0
--add-module=/usr/src/redhat/BUILD/nginx-1.0.8/ngx-lua-module-0.31rc9-0
--add-module=/usr/src/redhat/BUILD/nginx-1.0.8/ngx_auth_request-module
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386
-mtune=generic -fasynchronous-unwind-tables'

Still seeing some evil type behaviour though.

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

Cheers



More information about the nginx mailing list