Welcome! Log In Create A New Profile

Advanced

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

John Griffin
April 07, 2010 08:04AM
Hey

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:
10.211.55.2, server: testing.com, request: "PUT /abc HTTP/1.1", host: "
testing.com"

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
there.

Thanks

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 {
internal;
}
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
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

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

John Griffin April 07, 2010 08:04AM

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

boof December 22, 2010 08:50AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 238
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready