<div dir="ltr">Nginx uses a variable "$proxy_internal_body_length" for the "Content-Length" header in http proxy module, which is cacheable and shared between the main request and all subrequests by default. Although ctx->internal_body_length is <span style="color:rgb(68,68,68);font-family:arial,sans-serif;line-height:16px">calculated for each request/subrequest, the string format is cached after the first </span><font color="#444444" face="arial, sans-serif"><span style="line-height:16px">generation, and this may be wrong for other subrequests.</span></font><div>
<font color="#444444" face="arial, sans-serif"><span style="line-height:16px"><br></span></font></div><div style><font color="#444444" face="arial, sans-serif"><span style="line-height:16px">The following simple config can reproduce the problem, where xxxxx is a place that can receive post data. curl --data-binary "xxxxxxxxxxxxxxx" localhost/test.html will cause the client hang.</span></font></div>
<div style><font color="#444444" face="arial, sans-serif"><span style="line-height:16px"><br></span></font></div><div style><font color="#444444" face="arial, sans-serif"><span style="line-height:16px"><div> location = /test.html {</div>
<div> add_after_body /vpost;</div><div><br></div><div> proxy_pass <a href="http://xxxxx">http://xxxxx</a>;</div><div> }</div><div><br></div><div> location /vpost {</div><div> proxy_set_body "in vpost";</div>
<div><br></div><div> proxy_pass <a href="http://xxxxx">http://xxxxx</a>;</div><div> }</div></span></font></div></div>