不带内容长度标头的PUT的nginx proxy_pass返回411

不带内容长度标头的PUT的nginx proxy_pass返回411,nginx,reverse-proxy,http-status-code-411,Nginx,Reverse Proxy,Http Status Code 411,我在使用nginx proxy_pass和PUT时遇到问题,没有返回411错误的内容长度头 我运行什么来测试这个: # curl -XPUT http://localhost:8080/ <html> <head><title>411 Length Required</title></head> <body bgcolor="white"> <center><h1>411 Length Require

我在使用nginx proxy_pass和PUT时遇到问题,没有返回411错误的内容长度头

我运行什么来测试这个:

# curl -XPUT http://localhost:8080/
<html>
<head><title>411 Length Required</title></head>
<body bgcolor="white">
<center><h1>411 Length Required</h1></center>
<hr><center>nginx/1.1.19</center>
</body>
</html>
# touch temp
# curl -X PUT http://localhost:8080/ -T temp
{"response": "ok"}
我发现这个帖子似乎也有同样的问题:

有没有办法让nginx在没有内容长度头的情况下代理PUT请求


较新版本的nginx是否不存在此缺陷/限制?

升级到
nginx>=1.4.1
1.3.9
1.4.0
就足够了,但存在安全问题thx@elhefe-请参阅注释)或按上述方式安装。对于Debian和RedHat家族来说,这是一个很好的选择

Debian

  • 气喘后遗症(目前为1.4.4-1)

    添加到
    /etc/apt/sources。列表

    deb http://ftp.debian.org/debian/ wheezy-backports main
    
    deb http://nginx.org/packages/debian/ wheezy nginx
    deb-src http://nginx.org/packages/debian/ wheezy nginx
    
    运行并安装您选择的nginx版本(
    nginx full
    nginx light
    nginx naxsi

  • nginx.org包(稳定版本目前为1.4.4):

    添加到
    /etc/apt/sources。列表

    deb http://ftp.debian.org/debian/ wheezy-backports main
    
    deb http://nginx.org/packages/debian/ wheezy nginx
    deb-src http://nginx.org/packages/debian/ wheezy nginx
    
    删除当前的nginx包:

    apt-get remove nginx-full nginx-common
    
    更新包列表:

    apt-get update
    apt-get install nginx
    
    对于类似Debian的行为更改更新
    /etc/nginx/nginx.conf

    user  www-data;
    
    并在
    http
    部分末尾添加

    include /etc/nginx/sites-enabled/*;
    

没有主体的PUT从curl开始工作的重复注释。不确定这是添加零头还是nginx(假设没有头意味着0长度)。“nginx假设没有头意味着零长度”这就是HTTP规范所说的“请求中存在消息体是通过在请求的消息头中包含内容长度或传输编码头字段来表示的。”No length=No body。他们显然在较新版本的nginx中解决了这一问题,但我还没有时间对其进行测试。请注意,您不应该升级到nginx 1.3.9或1.4.0:
include /etc/nginx/sites-enabled/*;