tomcatnginxjerseychunked-encoding

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


Solution

  • 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