nginx 下载文件 upstream sent invalid chunked response while reading upstream 错误

1,166 阅读1分钟

前言

直接从服务端下载正常,然后经nginx路由下载报错
在这里插入图片描述

查看nginx error.log, 异常如下:

2021/01/11 12:39:06 [error] 62859#62859: *78173 upstream sent invalid chunked response while reading upstream,
2021/01/11 12:39:13 [error] 62859#62859: *78197 upstream sent invalid chunked response while reading upstream,
2021/01/11 12:39:18 [error] 62859#62859: *78207 upstream sent invalid chunked response while reading upstream,
2021/01/11 12:39:33 [error] 62859#62859: *78209 upstream sent invalid chunked response while reading upstream,
2021/01/11 12:39:50 [error] 62859#62859: *78211 upstream sent invalid chunked response while reading upstream,
2021/01/11 12:40:16 [error] 62859#62859: *78250 upstream sent invalid chunked response while reading upstream,

解决

原因就是Http1.0不支持长连接、分块传输,改为1.1版本即可

http1.0是建立连接,发送请求信息,接收请求信息,断掉连接.不支持分块传递,所以nginx报错了.

nginx官网传送门
设置用于代理的HTTP协议版本。默认情况下,使用版本1.0。建议将1.1版

句法:	proxy_http_version 1.0 | 1.1;
默认:	proxy_http_version 1.0;
内容:	http,server,location
该指令出现在版本1.1.4中。

设置为:

proxy_http_version 1.1;

即可