proxy_pass takes Content-Length from another subrequest
lanshun zhou
zls.sogou at gmail.com
Fri May 3 03:26:11 UTC 2013
You can either use separated variables between the main request and
subrequests by creating new ones for subrequest after calling
ngx_http_subrequest, or mark variable "$proxy_internal_body_length" as
no_cacheable.
See http://mailman.nginx.org/pipermail/nginx-devel/2013-May/003669.html for
more details.
2013/5/2 Marat Dakota <dakota at brokenpipe.ru>
> 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
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130503/0bc85769/attachment.html>
More information about the nginx-devel
mailing list