<div dir="ltr"><span style="font-size:13px">Hi All,</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">I'm writing a content phase handler module, which executes sub requests to an internal location in my nginx config, and in specific, a proxy_pass. It also modifies headers, request body, and response body as the request streams through.</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">location / {</span><br style="font-size:13px"><span style="font-size:13px">  my_module;</span><br style="font-size:13px"><span style="font-size:13px">}</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">location /internal {</span><br style="font-size:13px"><span style="font-size:13px">  proxy_pass http://....</span><br style="font-size:13px"><span style="font-size:13px">}</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">GET requests work ok, but for PUT, the entire body has to first be read in by my module, because request_body_no_buffering does not work for sub requests.</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">I got around this for the PUT sub request  by adding a flag to ngx_connection_t, wrapping the ngx_connection_t ->recv function with my own function, and finally modifying the sub request check in ngx_http_read_client_</span><span style="font-size:13px">request_body to be ignored if my flag is set.</span><div style="font-size:13px"><br></div><div style="font-size:13px">The recv wrapper is necessary, because the content length header in the sub request is larger than the content length in the main request, and ngx_http_request_body.c does its accounting based on the recv function, and not ngx_http_top_request_body_filter.<br><br>Is there a better way of doing this?<br><br>Any feedback or suggestions would be greatly appreciated.<br><br>Thanks!</div><div style="font-size:13px">John</div></div>