首页 > 解决方案 > nginx ingress 中的 body 大小到底是多少?

问题描述

我正在尝试为 proxy-body-size 注释设置一个值,但我确定如何得出相同的数字。例如,如果我推送价值 2GB 的数据,则 1GB 的主体大小会引发“413 请求太大”错误,而 3GB 的限制可以正常工作。

所以我想了解nginx中的body size到底是什么。它是整个数据的数据包/较小部分还是整个数据(比如上面提到的我正在推动的 2GB)。

任何帮助将不胜感激。

标签: nginxkubernetesnginx-ingress

解决方案


您必须在请求正文中设置允许的最大大小。因此,您必须将值设置为大于您尝试推送的数据大小。

从文档 https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md#custom-max-body-size

Custom Body Size: For NGINX, an 413 error will be returned to the client when the size in a request exceeds the maximum allowed size of the client request body. This size can be configured by the parameter client_max_body_size.

To configure this setting globally for all Ingress rules, the proxy-body-size value may be set in the NGINX ConfigMap. To use custom values in an Ingress rule define these annotation:
nginx.ingress.kubernetes.io/proxy-body-size: 8m

推荐阅读