在ingress-nginx-controller的configmap里添加enable-underscores-in-headers: "true"即可。如下:
apiVersion: v1
data:
allow-snippet-annotations: "true"
enable-underscores-in-headers: "true"
use-forwarded-headers: "true"
kind: ConfigMap
metadata:
annotations:
meta.helm.sh/release-name: ingress-nginx
meta.helm.sh/release-namespace: ingress-nginx
creationTimestamp: "2022-03-01T10:07:59Z"
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/version: 1.1.1
helm.sh/chart: ingress-nginx-4.0.15
managedFields:
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:data:
.: {}
f:allow-snippet-annotations: {}
f:use-forwarded-headers: {}
f:metadata:
f:annotations:
.: {}
f:meta.helm.sh/release-name: {}
f:meta.helm.sh/release-namespace: {}
f:labels:
.: {}
f:app.kubernetes.io/component: {}
f:app.kubernetes.io/instance: {}
f:app.kubernetes.io/managed-by: {}
f:app.kubernetes.io/name: {}
f:app.kubernetes.io/version: {}
f:helm.sh/chart: {}
manager: helm
operation: Update
time: "2022-03-01T10:07:59Z"
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:data:
f:enable-underscores-in-headers: {}
manager: agent
operation: Update
time: "2022-03-02T03:02:20Z"
name: ingress-nginx-controller
namespace: ingress-nginx
resourceVersion: "551612"
uid: 64e6051a-ba0d-4e52-952f-c86dc7c27180