<div>Hey</div><div><br></div>I am using nginx to proxy couchdb. Performing the following returns a 411 Length Required:<div><br></div><div>curl -X PUT <a href="https://testing.com/abc">https://testing.com/abc</a> --insecure --user john</div>
<div><br></div><div>Whereas passing a length of 0 in works fine:</div><div><br></div><div>curl -X PUT <a href="https://testing.com/abc">https://testing.com/abc</a> --insecure --header Content-Length:0 --user john</div><div>
<br></div><div>Logging also shows it was rejected:</div><div><br></div><div>2010/04/03 14:41:20 [info] 22970#0: *1 client sent PUT method without &quot;Content-Length&quot; header while reading client request headers, client: 10.211.55.2, server: <a href="http://testing.com">testing.com</a>, request: &quot;PUT /abc HTTP/1.1&quot;, host: &quot;<a href="http://testing.com">testing.com</a>&quot;</div>
<div><br></div><div>It seems that this was fixed for POSTs in <span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">0.7.25 but not for PUTs. Shouldn&#39;t PUTs be allowed without a Content-Length set?</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br>
</span></font></div><div><span class="Apple-style-span" style="font-size: 13px; "></span><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">My config is below including an attempt to use <span class="Apple-style-span" style="border-collapse: separate; font-family: arial; white-space: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; ">proxy_set_header to set the content-length. Unfortunately nginx rejects the request before it gets there.</span></span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span class="Apple-style-span" style="font-family: arial; "></span><span class="Apple-style-span" style="border-collapse: separate; white-space: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px;">Thanks</span></span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre-wrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span class="Apple-style-span" style="border-collapse: separate; white-space: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px;">John Griffin<br>
</span></span></font><div><br></div><div><div>server {</div><div>        listen   80;</div><div>        server_name <a href="http://testing.com">testing.com</a>;</div><div>        rewrite ^/(.*) <a href="https://testing.com/$1">https://testing.com/$1</a> permanent;</div>
<div>}</div><div><br></div><div><br></div><div>server {</div><div>        listen   443;</div><div>        ssl    on;</div><div>        ssl_certificate    /etc/ssl/certs/myssl.crt;</div><div>        ssl_certificate_key    /etc/ssl/private/myssl.key;</div>
<div>        server_name <a href="http://testing.com">testing.com</a>;</div><div>        access_log /home/john/public_html/<a href="http://testing.com/logs/access.log">testing.com/logs/access.log</a>;</div><div>        error_log /home/john/public_html/<a href="http://testing.com/logs/error.log">testing.com/logs/error.log</a> debug;</div>
<div>        error_page    502 503 504    /error/50x.html;</div><div>        location    /error/50x.html {</div><div>                internal;</div><div>        }</div><div>        location / {</div><div>                set $new_length $content_length;</div>
<div>                if ($new_length = &quot;&quot;) {</div><div>                        set $new_length &quot;0&quot;;</div><div>                }</div><div>                auth_basic &quot;Restricted&quot;;</div><div>                auth_basic_user_file /etc/sites/htpasswd/<a href="http://testing.com">testing.com</a>;</div>
<div>                proxy_pass <a href="http://localhost:5984">http://localhost:5984</a>;</div><div>                proxy_redirect off;</div><div>                proxy_set_header Content-Length $new_length;</div><div>                proxy_set_header Host $host;</div>
<div>                proxy_set_header X-Real-IP $remote_addr;</div><div>                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</div><div>        }</div><div>}</div><div><br></div><div><br></div></div>
</div>