# Content-Length header missing after proxying

**URL:** <https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021>\
**Category:** NGINX\
**Created:** [August 23, 2011, 8:44pm UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021 "2011-08-23T20:44:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [August 23, 2011, 8:44pm UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/1 "2011-08-23T20:44:35Z")

</div>

I have nginx configured to proxy to an upstream using the following  
in nginx.conf:

http {  
upstream app {  
server localhost:8080;  
}

```
 server {
     listen 80;

     location / {
proxy_pass http://app;
# proxy_pass_header Content-Length;

```

}  
}  
}

The upstream returns some data with the HTTP Content-Length header  
set. Using wget to connect directly I see:

Connecting to localhost|127.0.0.1|:8080… connected.  
HTTP request sent, awaiting response…  
HTTP/1.0 200 OK  
Content-Type: application/x-javascript  
Connection: keep-alive  
Content-Length: 44552  
Length: 44552 (44K) [application/x-javascript]

When I make a request via nginx however, the Content-Length header is  
no longer present (again using wget):

Connecting to localhost|127.0.0.1|:80… connected.  
HTTP request sent, awaiting response…  
HTTP/1.1 200 OK  
Server: nginx/1.0.5  
Date: Tue, 23 Aug 2011 18:40:30 GMT  
Content-Type: application/x-javascript  
Connection: close  
Length: unspecified [application/x-javascript]

Is there any obvious reason this should be happening, or something I’m  
doing wrong? The proxy\_pass\_header directive in the configuration file  
seems to make no difference to the outcome when I uncomment it.

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![James\_Fidell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f1d935/32.png) [@James\_Fidell](https://www.ruby-forum.com/u/James_Fidell)\
**Post date:** [August 24, 2011, 7:28am UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/2 "2011-08-24T07:28:13Z")

</div>

please help give out the info " nginx -V" , then we can give your help.

thanks  
george

---

<div class="post-metadata">

**Author:** ![James\_Fidell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f1d935/32.png) [@James\_Fidell](https://www.ruby-forum.com/u/James_Fidell)\
**Post date:** [August 24, 2011, 8:14am UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/3 "2011-08-24T08:14:29Z")

</div>

Hello!

On Tue, Aug 23, 2011 at 07:44:20PM +0100, James Fidell wrote:

> Connecting to localhost|127.0.0.1|:8080… connected.
> 
> Is there any obvious reason this should be happening, or something I’m  
> doing wrong? The proxy\_pass\_header directive in the configuration file  
> seems to make no difference to the outcome when I uncomment it.

I suspect that you aren’t using the config you provided above, but  
instead additionally have something like ssi enabled, i.e.  
something like

```
ssi on;
ssi_types application/x-javascript;

```

also present in your config.

Maxim D.

---

<div class="post-metadata">

**Author:** ![James\_Fidell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f1d935/32.png) [@James\_Fidell](https://www.ruby-forum.com/u/James_Fidell)\
**Post date:** [August 24, 2011, 9:47am UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/4 "2011-08-24T09:47:08Z")

</div>

On 24/08/11 06:27, Geoge.Q wrote:

> please help give out the info " nginx -V" , then we can give your help.

$ /usr/local/nginx/sbin/nginx -V  
nginx: nginx version: nginx/1.0.5  
nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)  
nginx: TLS SNI support disabled  
nginx: configure arguments: --with-http\_ssl\_module --user=nginx  
–group=nginx

James

---

<div class="post-metadata">

**Author:** ![James\_Fidell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f1d935/32.png) [@James\_Fidell](https://www.ruby-forum.com/u/James_Fidell)\
**Post date:** [August 24, 2011, 9:53am UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/5 "2011-08-24T09:53:57Z")

</div>

On 24/08/11 07:14, Maxim D. wrote:

> I suspect that you aren’t using the config you provided above, but  
> instead additionally have something like ssi enabled, i.e.  
> something like
> 
> ```
> ssi on;
> ssi_types application/x-javascript;
> 
> ```
> 
> also present in your config.

Unfortunately not ☹

It isn’t the config that I’ll be using in production, but with the  
exception of a couple of lines I’m hoping are not relevant to the  
problem, it is the config that I’m using to try to track down what’s  
going wrong. For completeness though, here’s what I have:

# cat nginx.conf

worker\_processes 1;

events {  
worker\_connections 1024;  
}

http {  
upstream app {  
server localhost:8080;  
}

```
server {
    listen 80;

    location / {
            proxy_pass http://app;
            # proxy_pass_header Content-Length;
    }
}

```

}

nginx running with that configuration produced exactly the output from  
wget that I showed in my original email.

James

---

<div class="post-metadata">

**Author:** ![James\_Fidell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f1d935/32.png) [@James\_Fidell](https://www.ruby-forum.com/u/James_Fidell)\
**Post date:** [August 24, 2011, 12:38pm UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/6 "2011-08-24T12:38:31Z")

</div>

On Wed, Aug 24, 2011 at 08:53:45AM +0100, James Fidell wrote:

> events {
> 
> ```
> location / {
> proxy_pass http://app;
> # proxy_pass_header Content-Length;
> }
> }
> 
> ```
> 
> }
> 
> nginx running with that configuration produced exactly the output from  
> wget that I showed in my original email.

Then only debug log may help:

> **[A debugging log](http://nginx.org/en/docs/debugging_log.html)**

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![James\_Fidell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f1d935/32.png) [@James\_Fidell](https://www.ruby-forum.com/u/James_Fidell)\
**Post date:** [August 24, 2011, 1:21pm UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/7 "2011-08-24T13:21:10Z")

</div>

On 24/08/11 11:37, Igor S. wrote:

> Then only debug log may help:  
> [A debugging log](http://nginx.org/en/docs/debugging_log.html)

And it did. Thank you.

When I connect to the application with wget it uses HTTP/1.1, which gets  
a content-length header in the response. nginx is connecting using  
HTTP/1.0, which doesn’t.

I’m guessing there’s not a whole lot I can do about that?

James

---

<div class="post-metadata">

**Author:** ![James\_Fidell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f1d935/32.png) [@James\_Fidell](https://www.ruby-forum.com/u/James_Fidell)\
**Post date:** [August 24, 2011, 2:21pm UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/8 "2011-08-24T14:21:45Z")

</div>

On Wed, Aug 24, 2011 at 12:20:49PM +0100, James Fidell wrote:

> I’m guessing there’s not a whole lot I can do about that?

It’s strange that the application sends Content-Length for HTTP/1.1.  
It’s valid header in HTTP/1.0. HTTP/1.1 allows to send chunked response  
without length.

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![James\_Fidell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f1d935/32.png) [@James\_Fidell](https://www.ruby-forum.com/u/James_Fidell)\
**Post date:** [September 6, 2011, 4:04pm UTC](https://www.ruby-forum.com/t/content-length-header-missing-after-proxying/211021/9 "2011-09-06T16:04:21Z")

</div>

Hello outside there,

I’m working on a corresponding issue  
To get removed\_email\_address@domain.invalid through an ssl-offload proxy I’ve set the  
following nginx configuration:

upstream nodejs3001 {  
server 127.0.0.1:3001;  
}

server {  
listen 127.0.0.1:84;  
server\_name portal.domain.tld;  
access\_log /var/log/nginx/customlogfile.log;

```
location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://nodejs3001;
    proxy_redirect off;
}

```

}

this is the last log-entry:  
192.168.1.123 - admin [06/Sep/2011:15:28:37 +0200] “GET  
/socket.io/1/xhr-polling/1502126590706860217?t1315315712123 HTTP/1.1”  
200 0 “[http://127.0.0.1:84/](http://127.0.0.1:84/)” “Mozilla/5.0 (Macintosh; Intel Mac OS X  
10\_7\_1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220  
Safari/535.1”

and this is the content of the header regarding to get this last step:  
Request  
URL:[http://127.0.01:84/socket.io/1/xhr-polling/1603386210380646057?t1315315788760](http://127.0.01:84/socket.io/1/xhr-polling/1603386210380646057?t1315315788760)  
Request Headersview source  
Referer:[http://127.0.0.1:84/](http://127.0.0.1:84/)  
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_7\_1)  
AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1  
Query String Parametersview URL encoded

I think we’ll have the most success here:  
[https://github.com/ajaxorg/cloud9/issues/267](https://github.com/ajaxorg/cloud9/issues/267)

Tell me… Are you trying to do the same?  
µatthias
