Files
doc/nginx-ingress常见问题.md
2025-10-16 17:32:48 +08:00

47 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# nginx-ingress常见问题
nginx-ingress相比较与traefik-ingress对开发者而言貌似少了一些亲和力
很多东西都要自己配置
**413报错**
就是上传的文件大小超过限制的报错
今天在捣鼓自己的仓库的时候发现的,命名中转服务器设置了
```
client_max_body_size 0;
```
但是还是出现413的报错那么问题就出在集群的nginx-ingress了
查看日志定位了问题
2025/10/16 08:08:59 [error] 4876#4876: *2094938 client intended to send too large body: 288100865 bytes, client: 10.0.0.1, server:....
于是去网上查找解决方案:
### 配置ingress
```
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gitea
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "500m"
```
给对应服务的ingress添加annotation: nginx.ingress.kubernetes.io/proxy-body-size: "500m"
个人认为这是比较好的方法,对上传文件大小做更细的划分
还有一种配置全局的:
### 配置configmap
```
data:
proxy-body-size: 500m
```
找到对应的configmap根据[官方文档](https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#proxy-body-size)中的表述解决413报错需要配置proxy-body-size覆盖原有默认配置默认值只有1M