Reputation: 6392
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
Upvotes: 20
Views: 13499
Reputation: 337
You should add proxy_http_version 1.1
,
This directive appeared in version 1.1.4.
Sets the HTTP protocol version for proxying. By default, version 1.0 is used. Version 1.1 is recommended for use with keepalive connections and NTLM authentication.
Best way, Create a http_proxy.conf
file and include it in your server config:
## http_proxy.conf
proxy_buffers 32 4k;
proxy_http_version 1.1;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_set_header Connection '';
#proxy_set_header HEADER_NAME $VALUE;
## server.conf
server {
listen 80;
server_name example.domain.com
include /etc/nginx/http_proxy.conf;
#.....
}
Upvotes: 0
Reputation: 1798
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 "";
Upvotes: 6
Reputation: 6392
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
Upvotes: 30