nginx反向代理报错 an upstream response is buffered to a temporary file

作者:Garany 发布于:2018-05-30 分类:破万卷书
调整nginx的error日志到warn级别,发现大量的warn错误
2018/05/30 11:51:40 [warn] 14416#0: *33213457 an upstream response is buffered to a temporary file /usr/local/nginx/proxy_temp/3/88/0002331883 while reading upstream, client: 123.138.233.236, server: www.xxxxx.com, request: "GET /html_app/img/dashi/touxiang/37.jpg HTTP/1.1", upstream: "http://127.0.0.1:65012/html_app/img/dashi/touxiang/37.jpg", host: "www.xxxxx.com", referrer: "http://www.xxxxx.com/html_app/dashi.html"

1.原因:

nginx默认的buffer太小,请求头header太大时会出现缓存不足,写入到了磁盘中,造成访问中断。


2.解决办法:

2.1在 NGINX+PHP 模式中,NGINX作为WEB服务器,需要修改fastcgi_buffer_*的值。值的大小,根据相应页面大小调整。

在location段添加

 fastcgi_buffer_size 512k;

 fastcgi_buffers 6 512k;

 fastcgi_busy_buffers_size 512k;

 fastcgi_temp_file_write_size 512k;


2.2在 NGINX+Tomcat模式中,NGINX作为反向代理服务器,需要修改proxy_buffer*的值。值的大小,根据相应页面大小调整。

在location段添加

 proxy_buffering    off;     #开启从后端被代理服务器的响应内容缓冲

 proxy_buffer_size  128k;     #设置缓冲区的大小和数量

 proxy_buffers 100  128k;    

 client_max_body_size 100m;

标签: linux nginx

我来说说