PUTs without "Content-Length" header line are rejected with a 411

John Griffin johnog at gmail.com
Wed Apr 7 15:56:57 MSD 2010


I am using nginx to proxy couchdb. Performing the following returns a 411
Length Required:

curl -X PUT https://testing.com/abc --insecure --user john

Whereas passing a length of 0 in works fine:

curl -X PUT https://testing.com/abc --insecure --header Content-Length:0
--user john

Logging also shows it was rejected:

2010/04/03 14:41:20 [info] 22970#0: *1 client sent PUT method without
"Content-Length" header while reading client request headers, client:, server: testing.com, request: "PUT /abc HTTP/1.1", host: "

It seems that this was fixed for POSTs in 0.7.25 but not for PUTs. Shouldn't
PUTs be allowed without a Content-Length set?

My config is below including an attempt to use proxy_set_header to set the
content-length. Unfortunately nginx rejects the request before it gets


John Griffin

server {
        listen   80;
        server_name testing.com;
        rewrite ^/(.*) https://testing.com/$1 permanent;

server {
        listen   443;
        ssl    on;
        ssl_certificate    /etc/ssl/certs/myssl.crt;
        ssl_certificate_key    /etc/ssl/private/myssl.key;
        server_name testing.com;
        access_log /home/john/public_html/testing.com/logs/access.log;
        error_log /home/john/public_html/testing.com/logs/error.log debug;
        error_page    502 503 504    /error/50x.html;
        location    /error/50x.html {
        location / {
                set $new_length $content_length;
                if ($new_length = "") {
                        set $new_length "0";
                auth_basic "Restricted";
                auth_basic_user_file /etc/sites/htpasswd/testing.com;
                proxy_pass http://localhost:5984;
                proxy_redirect off;
                proxy_set_header Content-Length $new_length;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20100407/7fae0496/attachment.html>

More information about the nginx mailing list