gpt4 book ai didi

ssl - ssl-passthrough 是在主机级别配置的,kubernetes ingress

转载 作者:行者123 更新时间:2023-12-04 22:39:40 29 4
gpt4 key购买 nike

我在kubernetes中有2个服务,一个是mtls,另一个是tls。
我正在尝试为他们配置入口。
我想为 mtls 服务配置 ssl passthrough,但不使用 ssl-passthrough 离开 tls 服务,它不需要客户端证书。
我用两个不同的 yaml 文件在同一个主机名上配置了 2 个入口。
一个有直通,另一个没有直通。
当前的行为是,如果我首先创建 mtls 入口,则 tls 将不起作用,我发送给 tls 的 https 请求将始终路由到 mtls 服务。然后返回 404。
但是,如果我先配置 tls ingress,然后再配置 mtls。然后 tls 将工作,但 mtls 将因证书问题而失败。
我不确定是否在主机级别配置了 ssl passthrough 注释?或者我可以让它在每个路径级别上工作吗?
mtls 入口。

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
ingress.kubernetes.io/ssl-passthrough: "true"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
nginx.ingress.kubernetes.io/ssl-redirect: "false"
name: mtls-ingress
spec:
rules:
- host: app.abc.com
http:
paths:
- backend:
service:
name: mtls-service
port:
number: 8081
path: /mtls-api
pathType: Prefix
tls:
- hosts:
- app.abc.com
secretName: tls-nginx-mtls
然后 tls 入口:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
nginx.ingress.kubernetes.io/ssl-redirect: "false"
name: tls-ingress
spec:
rules:
- host: app.abc.com
http:
paths:
- backend:
service:
name: tls-service
port:
number: 8080
path: /tls-api
pathType: Prefix
tls:
- hosts:
- app.abc.com
secretName: tls-nginx-tls
这就像两个入口相互覆盖,只有第一个注释有效。看起来为主机配置了直通,但没有为入口或路径配置。
不知道。请帮忙。谢谢。

最佳答案

您想在同一主机上使用带有注释 nginx.ingress.kubernetes.io/ssl-passthrough: "true" 的 2 个服务为其中之一。
这将不起作用,因为使用 SSL Passthrough 代理不知道路由流量的路径。
来自 the NGINX Ingress Controller User Guide :

The annotation nginx.ingress.kubernetes.io/ssl-passthrough instructsthe controller to send TLS connections directly to the backend insteadof letting NGINX decrypt the communication.

Because SSL Passthrough works on layer 4 of the OSI model (TCP) andnot on the layer 7 (HTTP), using SSL Passthrough invalidates all theother annotations set on an Ingress object.


解决方案是为您的服务使用子域,而不是路径。
此外,来自 GitHub 的一些关于此问题的链接:
Multiple Ingress backends ignored when SSL Passthrough is enabled
Ignoring SSL Passthrough for location "/*" in server "example.com"
Path based routing only works with base path
来自 serverfault关于 SSL Passthrough 的 NginX 工作流程。

关于ssl - ssl-passthrough 是在主机级别配置的,kubernetes ingress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70785851/

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