k8s Ingress 添加支持带有下划线的Header参数

释放双眼,带上耳机,听听看~!

在k8s环境中,一般前端代理都使用Ingress进行代理,开发调用传参的时候会遇到头部名称带下划线的需求,这种前端调用带下划线会被Ingress丢弃掉,这个问题估计很多人都遇到过。在Ingress官方文档中默认Enables underscores in header names. default: is disabled是为false的

如果我们需要Ingress支持前端传参带下划线的需求,需要在Ingress的configmap种开启并配置enable-underscores-in-headers参数

修改Ingress configmap

kind: ConfigMap
apiVersion: v1
metadata:
  name: abcdocker-nginx
  namespace: ingress
  annotations:
    control-plane.alpha.kubernetes.io/leader: >-
      {"holderIdentity":"abcdocker-nginx-85679f444d-dqxh6","leaseDurationSeconds":30,"acquireTime":"2023-01-31T09:37:23Z","renewTime":"2023-06-07T03:00:17Z","leaderTransitions":24}
data:
  enable-underscores-in-headers: 'true'   #此处添加

#请不要直接复制,根据自己需求添加data标签复制

如果是nginx 出现想支持下划线的header请求,需要在http标签下添加underscores_in_headers on;

给TA打赏
共{{data.count}}人
人已打赏
NGINX报错锦集

Nginx pstream prematurely closed connection while reading response header from upstream

2023-6-7 14:06:20

Linux报错锦集

Keeplived VRRP异常出现脑裂

2023-6-25 11:10:04

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索