Nginx [error] 34948#38560: *6 upstream sent invalid chunked response while reading response

[error] 34948#38560: *6 upstream sent invalid chunked response while reading response header from upstream

报错特征

1.logs/error.log: upstream sent invalid chunked response while reading response header from upstream
2.浏览器访问控制台提示错误:Failed to load resource: net::ERR_EMPTY_RESPONSE
3.Postman 测试报错:Could not get response Error: socket hang up
4.get、post请求都有响应,但put方法访问报以上1、2、3类型错误

1.杀掉所有Nginx进程

# Windows
taskkill /f /im nginx.exe
# Linux
ps -ef |grep nginx|awk '{print "kill -9" $2}' | sh

2.Nginx conf 修改

server {
        listen       8181;
        server_name  localhost;
        
        #charset koi8-r;

        root D:\dist;

        # 代理系统接口
        location /  {
            try_files $uri $uri/ /index.html;
        }

        # 网关
        location /web {
            proxy_pass http://127.0.0.1:8080;
            # 重点!!!添加这两条。如果已经添加过或者重启了很多次还是不行。请再次确认一下
            # 是否杀掉了所有Nginx进程,保证确实是重启了。因为我在重启了很多次不生效,
            # 最终杀掉进程重启解决了问题。
            # 如果以上确实操作后还不行,那可能在此基础上还需检查proxy_temp 是否拥有权限
            # 或者还存在其他问题。
            proxy_http_version 1.1;
            proxy_set_header Connection "";
        }
   }

proxy_http_version 1.1;
proxy_set_header Connection "";

3.重新启动Nginx

你可能感兴趣的:(nginx,运维)