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 have the following setup - node-http-proxy acts as a reverse proxy forwarding all requests to nginx/socket.io as necessary

My problem is this When I send a HTTP DELETE request from the browser, node-http-proxy adds a header "Transfer Encoding Chunked" as the request from the browser had no Content Length. The request from the browser had no Content Length as it had no body. Nginx doesn't like the Transfer Encoding Chunked Header and throws a 411 asking for Content-Length.

The problem gets solved when I send dummy data as part of the DELETE request so there is a Content Length and node-http-proxy doesn't add Transfer Encoding Chunked header and nginx is happy.

I want to understand if node-http-proxy isn't working as expected, because it adds a Transfer Encoding Chunked header when Content Length is missing because there is no Content Body.

EDIT - More info:

When I tried removing the node-http-proxy and directly sending the request to nginx, nginx is happy about it. Please note, neither Content Length(as the body is emtpy) nor Transfer Encoding Chunked is set by the browser

share|improve this question

2 Answers 2

I have experienced exactly the same issue in my set-up. Details can be found here: http://development.blog.saw.sonyx.net/2012/11/http-delete-failing-with-411.html

I ended up with patching http-proxy to add content-length for DELETE requests. You can find patch on my fork of http-proxy here:

https://github.com/ian7/node-http-proxy/commit/642a838093286da3b3b84726e38dcf3f8748f7f0

share|improve this answer

From RFC 2616 - "The presence of a message-body in a request is signaled by the inclusion of a Content-Length or Transfer-Encoding header field in the request's message-headers.". So I think nginx is right in expecting a Content-Length since it thinks it has a message-body.

You can try explicitly setting Content-Length to 0.
Also try: http://wiki.nginx.org/HttpChunkinModule

share|improve this answer
    
2 things to note. 1. When I tried sending nginx the request without "Transfer Encoding" header nor the Content Length, it doesn't complain 2. Whether to set Content Length or not is determined by the browser –  rampr Jun 6 '12 at 18:28
    
When Transfer Encoding Chunked is present, Content Length doesn't make sense, because the data is sent in chunks and the end of the data is signalled by a delimiter of some sort instead of the Content Length. –  rampr Jun 6 '12 at 18:36
    
This is a bug in node-http-proxy then. –  mgorven Jun 7 '12 at 6:01

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.