侧边栏壁纸
博主头像
★街角晚灯★博主等级

博观而约取 厚积而薄发

  • 累计撰写 461 篇文章
  • 累计创建 184 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

K8S Ingress 上传文413错误

WinJay
2024-01-02 / 0 评论 / 0 点赞 / 18 阅读 / 4079 字 / 正在检测是否收录...
温馨提示:
文章发布较早,内容可能过时,阅读注意甄别。。。。

K8S Ingress 上传文413错误

image-20240102161837353

1. 文件太大

413 Payload Too Large 413:Request Entity Too Large

企业微信截图_17034835297250

创建 ingress 时添加 annotations(注释); 在Ingress文件添加以下几行处理

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: info-rest
  namespace: lit
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "500M"	# 必须项
    nginx.ingress.kubernetes.io/client-max-body-size: "500M"

文件传输大小主要添加 nginx.ingress.kubernetes.io/proxy-body-size: "1024m" #此时传输到网站的文件最大可为1024MB

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: ingress-test-ce
 namespace: test
 annotations:
   kubernetes.io/ingress.class: "nginx"
   nginx.ingress.kubernetes.io/proxy-body-size: "1024m"
   nginx.ingress.kubernetes.io/ssl-redirect: "false" # 前端使用http访问Ingress,默认可能使用https链接Ingress
   nginx.ingress.kubernetes.io/rewrite-target: /$1   # ingress跳转后台的path重写规则

2. 上传超时

504:Gateway Timeout

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: info-rest
  namespace: lit
  annotations:
    nginx.ingress.kubernetes.io/proxy-send-timeout: "30s"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600s"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "30s"

3. http 的URI太长

当http 的URI太长或者request header过大时会报414 Request URI too large或400 bad request错误解决方法:

400 bad request 414 Request URI too large

//  修改两个参数

#=====参数一=====:
#client_header_buffer_size:客户端请求头缓冲区大小,
client_header_buffer_size 128k;#如果请求头总长度大于小于128k,则使用此缓冲区

#=====参数二=====:
#large_client_header_buffers:请求头总长度大于128k时使用large_client_header_buffers设置的缓存区
large_client_header_buffers 4 128k;
#large_client_header_buffers 指令参数4为个数,128k为大小,默认是8k。申请4个128k。 
apiVersion: v1
data:
  allow-backend-server-header: "true"
  enable-underscores-in-headers: "true"
  • 完整文件
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: info-web
  namespace: lit
  annotations:
    nginx.ingress.kubernetes.io/proxy-send-timeout: "30s"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600s"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "30s"
    nginx.ingress.kubernetes.io/proxy-body-size: "500M"
    nginx.ingress.kubernetes.io/client-max-body-size: "500M"
spec:
  defaultBackend:
    service:
      name: web-svc
      port:
        number: 80
  ingressClassName: nginx
  rules:
    - host: info.litsoft.com.cn
      http:
        paths:
          - backend:
              service:
                name: web-svc
                port:
                  number: 80
            path: /
            pathType: Prefix


---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: info-rest
  namespace: lit
  annotations:
    nginx.ingress.kubernetes.io/proxy-send-timeout: "30s"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600s"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "30s"
    nginx.ingress.kubernetes.io/proxy-body-size: "500M"
    nginx.ingress.kubernetes.io/client-max-body-size: "500M"
spec:
  defaultBackend:
    service:
      name: rest-svc
      port:
        number: 8080
  ingressClassName: nginx
  rules:
    - host: rest.litsoft.com.cn
      http:
        paths:
          - backend:
              service:
                name: rest-svc
                port:
                  number: 8080
            path: /
            pathType: Prefix
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区