首页 > 代码库 > nginx client_body_buffer_size
nginx client_body_buffer_size
这里分享一个关于 nginx client_body_buffer_size 参数的解决案例。
描述:前端同事反馈,在发POST 请求带参数的时候,过Nginx 会报错;但是单台测试tomcat,POST 很正常;看了下请求参数,好大一堆,的确比较多,问题应该在nginx上,于是查看nginx 报错日志,进行分析
现象:用Postman 测试发送请求,POST报错不成功,参数好大一堆。
查看nginx error 日志分析:
2016/09/13 12:40:59 [warn] 15598#0: *35462539 an upstream response is buffered to a temporary file /usr/local/nginx/proxy_temp/9/66/0001124669 while reading upstream, client: 116.226.84.138, server:*****.juxinli.com, request: "POST /devPlatformApi/rest/fengkong/variate_dir HTTP/1.1", upstream: "http://******/devPlatformApi/rest/fengkong/variate_dir", host: "***.***.com"
分析解决:从官方给出的定义,是client_body_buffer_size 参数定义过小而发送请求超过默认参数16K大小了。
Syntax: | client_body_buffer_size |
---|---|
Default: | client_body_buffer_size 8k|16k; |
Context: | http , server , location |
Sets buffer size for reading client request body. In case the request body is larger than the buffer, the whole body or only its part is written to a temporary file. By default, buffer size is equal to two memory pages. This is 8K on x86, other 32-bit platforms, and x86-64. It is usually 16K on other 64-bit platforms.
官方文档:
http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size
解决办法:client_body_buffer_size 1024k; 加大到1024K,因为默认16K 太小,请求参数过多时,会出现此类报错。
问题解除,恢复正常:
官方文档:
http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size
其他帖子:
https://my.oschina.net/linland/blog/373315?p=1
可以研读下,弄清楚该配置参数及解决方法。
本文出自 “好先生2020” 博客,请务必保留此出处http://fuyuan2016.blog.51cto.com/8678344/1853410
nginx client_body_buffer_size