gpt4 book ai didi

Kubernetes nginx 入口 Controller 不转发带下划线的 header

转载 作者:行者123 更新时间:2023-12-02 11:46:26 26 4
gpt4 key购买 nike

我遇到了一个问题,我的 kubernetes nginx 入口 Controller 是 不是 转发带有下划线的标题。
我创建了一个名为 my-release-ingress-nginx-controller 的 configMap带有以下条目。

    enable-underscores-in-headers: "true"
在此之后,我通过描述 nginx 入口 Controller pod 来检查 nginx.conf 文件,使用此命令 kubectl exec -it my-release-ingress-nginx-controller-d7648bcc8-6lfxv cat nginx.conf .我在那里找到了这个 underscores_in_headers on; .即使在这个切换之后,nginx 仍然没有转发带有下划线的 header 。
配置映射:
apiVersion: v1
kind: ConfigMap
metadata:
name: my-release-ingress-nginx-controller
namespace: default
data:
enable-underscores-in-headers: "true"
ignore-invalid-headers: "false"
ConfigMap 描述:
Name:         my-release-ingress-nginx-controller
Namespace: default
Labels: <none>
Annotations:
Data
====
enable-underscores-in-headers:
----
true
ignore-invalid-headers:
----
false
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CREATE 27s nginx-ingress-controller ConfigMap default/my-release-ingress-nginx-controller
部署描述
Args:
/nginx-ingress-controller
--publish-service=default/my-release-ingress-nginx-controller
--election-id=ingress-controller-leader
--ingress-class=nginx
--configmap=default/my-release-ingress-nginx-controller
入口描述:
Name:             ingress-resource-1
Namespace: default
Address: 172.31.14.220
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
api.dev.com
/ faq-dev:10013 (172.17.0.3:10013)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal UPDATE 3m10s (x2443 over 20h) nginx-ingress-controller Ingress default/ingress-resource-1
Normal UPDATE 2m10s (x2483 over 20h) nginx-ingress-controller Ingress default/ingress-resource-1
PS:我在 AWS ec2 服务器内使用 minikube 设置了一个单节点 kubernetes 集群。此外,入口被配置为部署而不是守护进程。配置的入口是来自这个存储库的 kubernetes - https://github.com/kubernetes/ingress-nginx

最佳答案

请试试这个

apiVersion: v1
kind: ConfigMap
data:
enable-underscores-in-headers: "true"
ignore-invalid-headers: "false"
metadata:
name: nginx-configuration
namespace: default
并在 nginx-ingress-controller-deployment 中包含相同的内容
containers:
- name: nginx-ingress-controller
image: <YOUR NGINX INGRSS IMAGE_NAME>
args:
- /nginx-ingress-controller
- --configmap=$(POD_NAMESPACE)/nginx-configuration
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace

关于Kubernetes nginx 入口 Controller 不转发带下划线的 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62949548/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com