nginx warn an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/ while reading upstream

时间:2022-07-07 12:33:02

最近管理的nginx发现大量的error log,log内容如下:

an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/0/52/0002923520 while reading upstream

从这条error日志来看是nginx某一块的buffer设置的太小,而response(包含response header和response body)导致response结果不得不临时写到文件中。

可以修改的配置参数

  client_header_buffer_size 128k;
client_body_buffer_size 1m;
proxy_buffer_size 32k;
proxy_buffers 64 32k;
proxy_busy_buffers_size 1m;
proxy_temp_file_write_size 512k;

经过这样的配置调整之后,基本上没有这样的error日志了。

关于这几个配置的官方文档链接如下

http://nginx.org/en/docs/http/ngx_http_core_module.html#directives

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#directives