We are partly delegating nginx access control to a separate service, and we use access_by_lua_file and lua-resty-hawk and subrequests to do the authentication of the request.
The docs say:
You should always read the request body (by either calling ngx.req.read_body or configuring lua_need_request_body on) before initiating a subrequest.
Originally we had missed this detail, things appeared to be working. I was trying to find more background information on this requirement but came up empty.
It would be nice to authorize the request before reading the body, since we may be able to terminate the connection early and prevent a kind of DoS attack if clients are just trying to upload all sorts of junk and fill our disk.
Why is this restriction in place?