Fork me on GitHub
如果对您有帮助,麻烦您点赞留言吧~~~

nginx报错upstream sent invalid chunked response while reading upstream

缘由:A项目用HttpURLConnection代理(B项目)内部接口的时候,返回值正常;
由于要走负载,nginx代理了几个A项目,通过nginx访问的时候,页面显示ERR_EMPTY_RESPONSE;
nginx报错upstream sent invalid chunked response while reading upstream.

原因

http协议版本不一致导致

解决方案

在nginx.conf的location里加上

proxy_http_version 1.1;
proxy_set_header   Connection       "";

举个例子

location /redirect/ {
	proxy_pass http://localhost:8080/;
	proxy_http_version 1.1;
	proxy_set_header   Connection       "";
	proxy_set_header   Host             $host;
	proxy_set_header   X-Real-IP        $remote_addr;
	proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
	proxy_set_header   X-Forwarded-Proto $scheme;
	proxy_cookie_path / /redirect;
}

完毕!

posted @ 2020-11-28 15:07  jarjune  阅读(1666)  评论(0编辑  收藏  举报