[BUG] Wrong Content-Length shared between main request and subrequests in http proxy module

lanshun zhou zls.sogou at gmail.com
Fri May 3 03:20:46 UTC 2013

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 calculated for each
request/subrequest, the string format is cached after the first generation,
and this may be wrong for other subrequests.

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.

      location = /test.html {
        add_after_body /vpost;

        proxy_pass http://xxxxx;

      location /vpost {
        proxy_set_body "in vpost";

        proxy_pass http://xxxxx;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130503/dce13d69/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proxy_internal_body_length.patch
Type: application/octet-stream
Size: 551 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130503/dce13d69/attachment.obj>

More information about the nginx-devel mailing list