twice chunked

Maxim Dounin mdounin at mdounin.ru
Wed Aug 10 14:45:49 UTC 2011


Hello!

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

> 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)

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).

2. 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 Dounin



More information about the nginx mailing list