错误信息:
upstream sent invalid chunked response while reading upstream, client: 61.157.18.xx, server: xx.xxx.com, request: "POST /api/mechanism/recommender HTTP/1.1", upstream: "http://127.0.0.1:31301/mechanism/recommender", host: "xx.xxx.com", referrer: "http://xx.xxx.com/"
问题排查:
1、通过url能访问,返回数据(curl -X POST “”)
2、通过工具能正常访问
请求协议为http/1.1而nginx代理后默认协议http版本是1.0,不支持分块传输
**
解决方案
**
改变nginx代理协议
nginx.conf 对应代理请求的location模块里面加上
proxy_http_version 1.1;
#设置Connection为空串,以禁止传递头部到后端
proxy_set_header Connection “”;
重启nginx
nginx -s reload