You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nginx Ingress Controller配置websockets及超时参数找不到对应annotations问题

Nginx Ingress Controller无对应原生参数Annotation的原因及配置方案

核心原因

  • Nginx Ingress Controller 的 Annotation 是官方针对高频通用场景做的上层封装,不会为所有 Nginx 原生指令单独适配独立 Annotation,避免 Annotation 体系过于冗余,仅覆盖绝大多数用户的通用配置需求。
  • 你提到的proxy_socket_keepalive、proxy_read_timeout、proxy_write_timeout都属于 Nginx 原生ngx_http_proxy_module支持的指令,官方未做对应 Annotation 是因为这类自定义配置可以通过官方提供的配置片段能力灵活注入,不需要单独开发独立注解。

配置实现方式

单Ingress规则生效

在对应Ingress资源的annotations中添加nginx.ingress.kubernetes.io/configuration-snippet注解,注入对应配置即可:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: your-ingress
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_socket_keepalive on;
      proxy_read_timeout 3600;
      proxy_write_timeout 3600;
spec:
  # 其余Ingress配置

全局所有Ingress规则生效

修改 Nginx Ingress Controller 对应的 ConfigMap(默认命名空间下名称一般为ingress-nginx-controller),添加如下配置:

data:
  proxy-socket-keepalive: "on"
  proxy-read-timeout: "3600"
  proxy-write-timeout: "3600"

内容的提问来源于stack exchange,提问作者pkaramol

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.14 09:15:07