I use nginx (v1.4.1) for an external service proxy, but would like to be able to check and possibly modify the request body POSTbefore proxying it. The problem is that currently I can’t access the body of the request POSTwhile processing the request, whether through a variable $request_bodyor otherwise.
I read a few posts and SO questions and implemented this proposed strategy , which is intended for body logging POSTusing the directive proxy_pass). However, although this works for me, I still cannot read anything from $request_bodyduring the processing of the request.
For clarity, here is the corresponding section of my configuration:
location /proxy-this/ {
client_max_body_size 8k;
client_body_buffer_size 16k;
client_body_in_single_buffer on;
proxy_pass https://example.com/external-endpoint/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header Content-Length '';
}
:
location /proxy-this/ {
... (same configuration as above) ...
set $request_body $request_body&extra_param=1;
}
, nginx_lua, HttpFormInputModule, , .