Welcome! Log In Create A New Profile


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

John Griffin
April 07, 2010 08:04AM

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;
nginx mailing list

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

John GriffinApril 07, 2010 08:04AM

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

boofDecember 22, 2010 08:50AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 72
Record Number of Users: 5 on August 04, 2015
Record Number of Guests: 244 on October 02, 2015
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready