java.io.IOException: Connection reset by peer

接口要是返回的是字节
1,首先查看本地调用是否能正常返回
2,其次判断同样的参数测试环境是否正常返回
3,本地要是正常,测试环境异常的话 很大可能就是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;
}

你可能感兴趣的:(java,开发语言,nginx)