lua_need_request_body ... limitations?

Nginx User nginx at nginxuser.net
Fri Oct 21 15:04:09 UTC 2011


So I managed to get my config going smoothly with "GET" requests as
outlined here: http://mailman.nginx.org/pipermail/nginx/2011-October/029901.html
with this correction
http://mailman.nginx.org/pipermail/nginx/2011-October/029903.html

I then decided to extend to cover "POST" requests.

Here is the calling location:

	location @proxy_no_cache {
		lua_need_request_body on;
		access_by_lua_file '/etc/nginx/firewall.lua';
		...
		proxy_pass http://127.0.0.1:8080;
		...
	}

firewall.lua contains:

...
-- Check "GET" Args
	local args = ngx.req.get_uri_args()
	for key, val in pairs(args) do
		if type(val) == "table" then
			my_arg = table.concat(val, ", ")
		else
			my_arg =  val
		end
		if my_arg and type( my_arg ) ~= "boolean" then
			dofile("/etc/nginx/regex_rules.lua")
		end
	end
	
-- Check "POST" Args
	local args = ngx.req.get_post_args()
	for key, val in pairs(args) do
		if type(val) == "table" then
			my_arg = table.concat(val, ", ")
		else
			my_arg =  val
		end
		if my_arg and type( my_arg ) ~= "boolean" then
			dofile("/etc/nginx/regex_rules.lua")
		end
	end
	ngx.exit(ngx.OK)

The 'Check "GET" Args' bit works fine but the 'Check "POST" Args' bit
falls over with ...
'lua handler aborted: runtime error: /etc/nginx/firewall.lua:54: no
request body found; maybe you should turn on lua_need_request_body?,
blah, blah, blah'


Question is that, are there limitations on calling
lua_need_request_body on that my set up does not meet?

Thanks.



More information about the nginx mailing list