使用 Istio 时如何正确地通过 HTTPS 保护应用程序?
How do I properly HTTPS secure an application when using Istio?
我目前正在努力思考结合 Istio 的 kubernetes 应用程序的典型应用程序流程是什么样的。
因此,对于我的应用程序,我有一个 asp.net 应用程序托管在 Kubernetes 集群中,并且我在上面添加了 Istio。这是我的网关和虚拟服务:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: appgateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
tls:
httpsRedirect: true
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
privateKey: /etc/istio/ingressgateway-certs/tls.key
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: appvservice
spec:
hosts:
- "*"
gateways:
- appgateway
tls:
- match:
- port: 443
sniHosts:
- "*"
route:
- destination:
host: frontendservice.default.svc.cluster.local
port:
number: 443
这是我在阅读 Istio 文档后想到的。
请注意,我的 frontendservice
是一个非常基本的 ClusterIP 服务路由到 Asp.Net 应用程序,该应用程序还提供标准的 80 / 443 端口。
我现在有几个问题:
- 这是保护我的应用程序的正确方法吗?本质上,我想将端口 80 上的传入流量直接重定向到边缘启用 https 的 443。但是,当我尝试这样做时,端口 80 上根本没有重定向。
- 此外,我的 VirtualService 上的 tls 路由不起作用。我的广告连播中没有流量
- 我也想知道,是否有必要手动将 HTTP 添加到我的内部应用程序,或者这是 Istios 内部 CA 功能的用武之地?
我想象它是这样工作的:
- 请求进来了。如果它在端口 80 上,发送重定向到客户端以发送 https 请求。如果它在端口 443 上,则允许该请求。
- VirtualService 提供有关端口 443 上的请求应该发生什么的说明,并将其转发给服务。
- 服务现在将请求转发到我的应用程序的 443 端口。
提前致谢 - 我刚刚学习 Istio,我有点困惑为什么我看似正确的设置在这里不起作用。
我们也在使用类似的设置。
- SSL 在入口网关上终止,但我们通过网关 CR 使用 mTLS 模式。
- 服务正在侦听非 SSL 端口,但 sidecar 在它们之间使用 mTLS,因此任何没有 sidecar 的容器都无法与服务通信。
- VirtualService 正在路由到非 ssl 服务端口。
- Sidecar CR 拦截进出非 ssl 服务端口的流量。
- PeerAuthentication 在 sidecar 之间设置 mTLS。
您的网关终止了 TLS 连接,但您的 VirtualService 配置为接受 unterminated TLS connections with TLSRoute。
比较 example without TLS termination and the example which terminates TLS. Most probably, the "default" setup would be to terminate the TLS connection and configure the VirtualService with a HTTPRoute.
我目前正在努力思考结合 Istio 的 kubernetes 应用程序的典型应用程序流程是什么样的。
因此,对于我的应用程序,我有一个 asp.net 应用程序托管在 Kubernetes 集群中,并且我在上面添加了 Istio。这是我的网关和虚拟服务:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: appgateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
tls:
httpsRedirect: true
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
privateKey: /etc/istio/ingressgateway-certs/tls.key
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: appvservice
spec:
hosts:
- "*"
gateways:
- appgateway
tls:
- match:
- port: 443
sniHosts:
- "*"
route:
- destination:
host: frontendservice.default.svc.cluster.local
port:
number: 443
这是我在阅读 Istio 文档后想到的。
请注意,我的 frontendservice
是一个非常基本的 ClusterIP 服务路由到 Asp.Net 应用程序,该应用程序还提供标准的 80 / 443 端口。
我现在有几个问题:
- 这是保护我的应用程序的正确方法吗?本质上,我想将端口 80 上的传入流量直接重定向到边缘启用 https 的 443。但是,当我尝试这样做时,端口 80 上根本没有重定向。
- 此外,我的 VirtualService 上的 tls 路由不起作用。我的广告连播中没有流量
- 我也想知道,是否有必要手动将 HTTP 添加到我的内部应用程序,或者这是 Istios 内部 CA 功能的用武之地?
我想象它是这样工作的:
- 请求进来了。如果它在端口 80 上,发送重定向到客户端以发送 https 请求。如果它在端口 443 上,则允许该请求。
- VirtualService 提供有关端口 443 上的请求应该发生什么的说明,并将其转发给服务。
- 服务现在将请求转发到我的应用程序的 443 端口。
提前致谢 - 我刚刚学习 Istio,我有点困惑为什么我看似正确的设置在这里不起作用。
我们也在使用类似的设置。
- SSL 在入口网关上终止,但我们通过网关 CR 使用 mTLS 模式。
- 服务正在侦听非 SSL 端口,但 sidecar 在它们之间使用 mTLS,因此任何没有 sidecar 的容器都无法与服务通信。
- VirtualService 正在路由到非 ssl 服务端口。
- Sidecar CR 拦截进出非 ssl 服务端口的流量。
- PeerAuthentication 在 sidecar 之间设置 mTLS。
您的网关终止了 TLS 连接,但您的 VirtualService 配置为接受 unterminated TLS connections with TLSRoute。
比较 example without TLS termination and the example which terminates TLS. Most probably, the "default" setup would be to terminate the TLS connection and configure the VirtualService with a HTTPRoute.