Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I use nginx with proxy path directive.
When the application to which the request is proxied return a response, it seems nginx add some header containing the Content-Length. Is that possible to remove this additional header ?

UPDATE

I have re-installed nginx with the more_headers module but I still have the same result. My config is:

upstream my_sock {
   server unix:/tmp/test.sock
   fail_timeout=0;
}

server {
   listen 11111;
   client_max_body_size 4G;
   server_name localhost;

   keepalive_timeout 5;

   location / {
      more_clear_headers 'Content-Length';
      proxy_pass http://my_sock;
      proxy_redirect off;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
    }
}
share|improve this question
add comment

2 Answers

You need to install the ngx_headers_more module, then use more_clear_headers:

http://wiki.nginx.org/NginxHttpHeadersMoreModule#more_clear_headers

more_clear_headers 

syntax: more_clear_headers [-t <content-type list>]... [-s <status-code list>]... <new-header>... 

default: no 

context: http, server, location, location if 

phase: output filter

In your specific case you probably want to add:

more_clear_headers 'Content-Length';
share|improve this answer
    
I still have the same problem. I have updated my question with the nginx config. Any idea ? –  Luc Sep 4 '11 at 18:42
add comment

This was due to the fact nginx talks to back ends in http 1.0 I needed to add the content-length in the response sent from the backend to avoid the encoding to be set to chunked.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.