Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NGINX Error: upstream sent invalid chunked response while reading upstream

We have tomcat with Jersey serving APIs behind NGINX. A new streaming API we have developed worked great when we call Tomcat directly, but started getting no response when calling it through NGINX.

Looking at NGINX logs we got:

upstream sent invalid chunked response while reading upstream

like image 423
galusben Avatar asked Mar 23 '18 14:03

galusben


2 Answers

We have solved the issue by adding the following to NGINX:

proxy_http_version 1.1

I guess NGINX proxies traffic by default with http version 1.0, but chunked transfer encoding is a http 1.1 feature.

https://forum.nginx.org/read.php?2,247883,247906#msg-247906

like image 199
galusben Avatar answered Nov 10 '22 12:11

galusben


In my case, only setting proxy_http_version 1.1 did not work. I had to set these -

proxy_http_version 1.1;
proxy_set_header Connection "";
like image 30
Ravi Kumar Gupta Avatar answered Nov 10 '22 14:11

Ravi Kumar Gupta