【Nginx】解决413错误

项目场景:

接收Excel文件


问题描述

调用该接口时发生413错误

接口服务nginx日志

2022/09/09 07:02:18 [error] 10#10: *6 client intended to send too large body: 3501022 bytes, client: 192.168.7.1, server: data-dispatch-center, request: "POST /api/v1/app/form/excel_import?nonce=p3cNGR×tamp=1662678138.514602 HTTP/1.1", host: "10.11.206.141:3121"
2022/09/09 07:02:23 [error] 10#10: *7 client intended to send too large body: 3501022 bytes, client: 192.168.7.1, server: data-dispatch-center, request: "POST /api/v1/app/form/excel_import?nonce=p3cNGR×tamp=1662678138.514602 HTTP/1.1", host: "10.11.206.141:3121"
2022/09/09 07:02:28 [error] 10#10: *8 client intended to send too large body: 3501022 bytes, client: 192.168.7.1, server: data-dispatch-center, request: "POST /api/v1/app/form/excel_import?nonce=p3cNGR×tamp=1662678138.514602 HTTP/1.1", host: "10.11.206.141:3121"
2022/09/09 08:23:15 [error] 10#10: *13 client intended to send too large body: 3432243 bytes, client: 192.168.7.1, server: data-dispatch-center, request: "POST /api/v1/app/form/excel_import?nonce=pszvLM×tamp=1662682994.933834 HTTP/1.1", host: "10.11.206.141:3121"
2022/09/09 08:23:20 [error] 10#10: *14 client intended to send too large body: 3432243 bytes, client: 192.168.7.1, server: data-dispatch-center, request: "POST /api/v1/app/form/excel_import?nonce=pszvLM×tamp=1662682994.933834 HTTP/1.1", host: "10.11.206.141:3121"
2022/09/09 08:23:25 [error] 10#10: *15 client intended to send too large body: 3432243 bytes, client: 192.168.7.1, server: data-dispatch-center, request: "POST /api/v1/app/form/excel_import?nonce=pszvLM×tamp=1662682994.933834 HTTP/1.1", host: "10.11.206.141:3121"

原因分析:

众所周知,413含义是“Request Entity Too Large”
nginx 配置文件中的client_max_body_size是控制请求body的大小限制的参数,默认为1MB,如果超过这个数值,则会直接返回413状态码
【Nginx】解决413错误_第1张图片


解决方案:

修改nginx配置文件

http {
    ...
    client_max_body_size 20M;
}  

参考:
http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
https://stackoverflow.com/a/62985236

你可能感兴趣的:(运维,NGINX,nginx,java,服务器)