Twice chunked

Hello,

i use nginx 1.1.0 as balancer in front of some apache-server. In some
cases, where the apache is generating bigger pages it sends content as
chunked, nginx is adding a second “chunked” to http-response header.
This is confusing Browsers and looks like:

Transfer-Encoding: chunked, chunked

nginx is compiled with:
nginx: nginx version: nginx/1.1.0
nginx: TLS SNI support enabled
nginx: configure arguments: --conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid
–lock-path=/var/lock/nginx.lock
–http-log-path=/var/log/nginx/access.log
–http-client-body-temp-path=/var/lib/nginx/body
–http-proxy-temp-path=/var/lib/nginx/proxy
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug
–with-http_stub_status_module --with-http_flv_module
–with-http_ssl_module --with-http_dav_module
–with-http_gzip_static_module --with-http_realip_module --with-mail
–with-mail_ssl_module --with-ipv6
–add-module=/usr/src/nginx-1.1.0-1/modules/nginx-upstream-fair

What can id do to avoid this double chunked in header? Parts of conf
needed? ( no special stuff in it)

Thanks,
Hajo

Posted at Nginx Forum:

Currently Nginx does not support chunked responses from backend servers.
There is a patch available in the dev forum/mailing list,however it is
still considered experimental and you’ll have to apply it to the source
yourself.

If you do not want to do this then you must force Apache to never return
chunked responses, that’s the only way this will work.

Posted at Nginx Forum:

Hello!

On Wed, Aug 10, 2011 at 09:42:29AM -0400, HajoLOcke wrote:

nginx: nginx version: nginx/1.1.0
–with-http_gzip_static_module --with-http_realip_module --with-mail
–with-mail_ssl_module --with-ipv6
–add-module=/usr/src/nginx-1.1.0-1/modules/nginx-upstream-fair

What can id do to avoid this double chunked in header? Parts of conf
needed? ( no special stuff in it)

There are two basic options:

  1. Fix backend to actually complain to HTTP specification (i.e.
    do not send chunked responses to HTTP/1.0 requests). You may try

    SetEnv downgrade-1.0

in Apache config. Alternatively, grep your php scripts for things like

header("HTTP/1.1 ...");

and change them to be “HTTP/1.0 …” (the problematic Apache
behaviour is caused by PHP module which sets r->proto_num to 1.1
if script uses header(“HTTP/1.1 …”), it should never ever do
that).

  1. Try patch which adds HTTP/1.1 support in nginx proxy module,
    see here:

http://mailman.nginx.org/pipermail/nginx/2011-August/028324.html

With the patch nginx understands chunked from http backends and
everything should be fine even if backend sends chunked over
HTTP/1.0 (you just need to compile with patch, no further actions
related to keepalive upstream connections required).

Maxim D.