proxy_pass takes Content-Length from another subrequest

Marat Dakota dakota at brokenpipe.ru
Thu May 2 00:23:22 UTC 2013


Hi.

My module makes a few subrequests with body (I populate sr->request_body
and set Content-Length in sr-headers_in).

These subrequests are landing to a locations that look like:

    location /backend {
        internal;
        rewrite /backend(.+) $1 break;
        proxy_pass http://mybackend;
    }

    location /backend2 {
        internal;
        rewrite /backend2(.+) $1 break;
        proxy_pass http://mybackend2;
    }

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.

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:

        while (*(uintptr_t *) e.ip) {
            code = *(ngx_http_script_code_pt *) e.ip;
            code((ngx_http_script_engine_t *) &e);
        }

I haven't managed to go deeper at the moment.

So, question is — am I doing something wrong or is it a bug?

Thanks.

--
Marat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130502/7805cf51/attachment.html>


More information about the nginx-devel mailing list