简体   繁体   English

Nginx在proxy_pass之后删除内容长度的HTTP标头

[英]nginx removes content length http header after proxy_pass


I have a problem that nginx removes the content-length header after the proxy pass. 我有一个问题,nginx在代理通过后删除了content-length标头。 the application back-end sends a gzip stream but specifies the content length. 应用程序后端发送gzip流,但指定内容长度。
NGINX changes the type content-type to chunked and removes the content length header. NGINX将内容类型的类型更改为分块,并删除内容长度标头。
This is not acceptable for the app since it is read not by the browser but by an proprietary app that requires the content-legth to be specified. 这对于应用程序是不可接受的,因为它不是由浏览器而是由要求指定内容长度的专有应用程序读取的。
After specified chunked_transfer_encoding off; 指定了chunked_transfer_encoding off; it stops adding the content type header but still removes the content length. 它会停止添加内容类型标头,但仍会删除内容长度。 How to disable any header modifications in nginx? 如何禁用Nginx中的任何标头修改?
The confing: 鸣叫:

upstream backend {
      server 127.0.0.1:9090;
}


server {
root /usr/share/nginx/www;
index index.html index.htm;

chunked_transfer_encoding       off;

        location / {
           proxy_pass  http://backend;
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
           proxy_redirect off;
           proxy_buffering off;
           proxy_set_header        Host            $host;
           proxy_set_header        X-Real-IP       $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
       }
}

This was a known bug in nginx in the past. 过去,这是nginx中的已知错误。 Update to the latest build. 更新到最新版本。

http://forum.nginx.org/read.php?2,216085,216085#msg-216085 http://forum.nginx.org/read.php?2,216085,216085#msg-216085

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM