<div dir="ltr">Hi.<div><br></div><div style>My module makes a few subrequests with body (I populate sr->request_body and set Content-Length in sr-headers_in).</div><div style><br></div><div style>These subrequests are landing to a locations that look like:</div>
<div style><div><br></div><div> location /backend {</div><div> internal;</div><div> rewrite /backend(.+) $1 break;</div><div> proxy_pass <a href="http://mybackend">http://mybackend</a>;<br></div><div>
}</div><div><br></div><div><div> location /backend2 {</div><div> internal;</div><div> rewrite /backend2(.+) $1 break;</div><div> proxy_pass <a href="http://mybackend2">http://mybackend2</a>;<br>
</div><div> }</div></div><div><br></div><div style>The problem is that proxy_pass takes Content-Length from the first subrequest and uses it for the second subrequest. So, when the first subrequest is longer than the second one, the second one never ends, and when the first one is shorter, the second backend (mybackend2) receives incomplete body.</div>
<div style><br></div><div style>I've spent quite a time tracing the problem and for the moment I've figured out that Content-Length comes from these lines in ngx_http_proxy_module.c:</div><div style><br></div><div style>
<div> while (*(uintptr_t *) e.ip) {</div><div> code = *(ngx_http_script_code_pt *) e.ip;</div><div> code((ngx_http_script_engine_t *) &e);</div><div> }</div><div><br></div><div style>
I haven't managed to go deeper at the moment.</div><div style><br></div><div style>So, question is — am I doing something wrong or is it a bug?</div><div style><br></div><div style>Thanks.</div><div style><br></div><div style>
--</div><div style>Marat</div></div></div></div>