9951 explained code solutions for 126 technologies


nginx-luaHow to get request body


server {
  location / {
    content_by_lua_block {
      local request_body = ngx.req.get_body_data()  
      ngx.say(request_body)
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

ngx.req.get_body_data()

returns full request body (posted data)

request_body

will contain request body

ngx.say

output given text to client