# Twice chunked

**URL:** <https://www.ruby-forum.com/t/twice-chunked/210537>\
**Category:** NGINX\
**Created:** [August 10, 2011, 3:43pm UTC](https://www.ruby-forum.com/t/twice-chunked/210537 "2011-08-10T15:43:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [August 10, 2011, 3:43pm UTC](https://www.ruby-forum.com/t/twice-chunked/210537/1 "2011-08-10T15:43:17Z")

</div>

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:

> **[twice chunked](https://forum.nginx.org/read.php?2,213632,213632#msg-213632)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![HajoLOcke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e99b99/32.png) [@HajoLOcke](https://www.ruby-forum.com/u/HajoLOcke)\
**Post date:** [August 10, 2011, 4:23pm UTC](https://www.ruby-forum.com/t/twice-chunked/210537/2 "2011-08-10T16:23:38Z")

</div>

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:

> **[Re: twice chunked](https://forum.nginx.org/read.php?2,213632,213633#msg-213633)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![HajoLOcke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e99b99/32.png) [@HajoLOcke](https://www.ruby-forum.com/u/HajoLOcke)\
**Post date:** [August 10, 2011, 4:46pm UTC](https://www.ruby-forum.com/t/twice-chunked/210537/3 "2011-08-10T16:46:34Z")

</div>

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

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:

> **[upstream keepalive - call for testing](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.
