Missing Content-Length in nginx response

Hello,

I have problems in a transition from Apache to nginx.

There are 2 nginx servers working together:
nginx (balancing, proxy) → another nginx → static files and php-fpm

Pages that are loaded through ajax doesn’t show up.

I checked through Firebug and the only differences are in following
response headers

  1. Transfer-Encoding chunked (presents only in Nginx response)
  2. Content-Length 571 (presents only in Apache response)…

How I can force nginx to work correctly here? Please see full dump of
headers below.

nginx 0.8.54
Tried to switch off gzip - it didn’t affect this issue at all.
ssl is not used in this configuration.
CentOS 5.5.

I appreciate any information regarding this issue

Best regards,
Ruslan D.

Nginx, doesn’t work correctly:

=== Response Headers
Server nginx
Date Thu, 14 Apr 2011 07:33:14 GMT
Content-Type text/html
Transfer-Encoding chunked
Connection keep-alive
X-Powered-By PHP/5.3.6
Set-Cookie PHPSESSID=790f5bfc9113be4f9ea34a6744aca983; path=/
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragmano-cache
Content-Encoding gzip

=== Request Headers
Host *****
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101
Firefox/4.0
Accept /
Accept-Languag een-us,ru;q=0.7,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Content-Type application/x-www-form-urlencoded
Referer http://www./
Origin http://www.

Another server, Apache:

=== Response Headers
Date Thu, 14 Apr 2011 07:26:40 GMT
Server Apache/2
X-Powered-By PHP/5.2.14
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma no-cache
Vary Accept-Encoding,User-Agent
Content-Encoding gzip
Content-Length 571
Keep-Alive timeout=1, max=100
Connection Keep-Alive
Content-Type text/html

=== Request Headers
Host *****
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101
Firefox/4.0
Accept*/*
Accept-Language en-us,ru;q=0.7,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive115
Connection keep-alive
Content-Type application/x-www-form-urlencoded
X-Requested-With XMLHttpRequest
Referer http://*****/

Hello!

On Thu, Apr 14, 2011 at 01:50:49AM -0600, Ruslan D. wrote:

response headers

  1. Transfer-Encoding chunked (presents only in Nginx response)
  2. Content-Length 571 (presents only in Apache response)…

How I can force nginx to work correctly here? Please see full dump of
headers below.

There is nothing incorrect in returning chunked response as long
as client uses HTTP/1.1.

I tend to think that your issue is unrelated. You may want to dig
further into your ajax code to see what actually goes wrong.

nginx 0.8.54
Tried to switch off gzip - it didn’t affect this issue at all.
ssl is not used in this configuration.
CentOS 5.5.

nginx uses chunked if (a) response length isn’t known (i.e.
backend doesn’t return it) or (b) it has to modify response body.

The (b) includes gzip filter, ssi filter, sub filter, addition
filter, and charset filter. With all of them switched off
(default) you should see original Content-Length from backend’s
response (if any).

Maxim D.