NGINX Ingress 控制器后端协议注释如何在基于路径的路由中工作? [英] How NGINX Ingress controller back-end protocol annotation works in path based routing?

查看:31
本文介绍了NGINX Ingress 控制器后端协议注释如何在基于路径的路由中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在 k8s 集群中使用 NGINX 入口控制器.我试图使端到端加密工作,并且我能够使连接一直安全到 Pod.

I'm currently playing with NGINX ingress controller in my k8s cluster. I was trying to make end-to-end encryption work and I was able to make the connection secure all the way to the pod.

为了实现 HTTPS 到 pod,不得不使用注解

In order to achieve HTTPS all the way till pod, I had to use annotation

nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"

样本入口:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: foo-api-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
  tls:
  - hosts:
    - foo.example.com
    secretName: foo-cert
  rules:
  - host: foo.example.com
    http:
      paths:
      - path: /path1
        backend:
          serviceName: foo-api-path1-service
          servicePort: 443
      - path: /path2
        backend:
          serviceName: foo-api-path2-service
          servicePort: 443

我很困惑这到底是怎么发生的,因为当我们加密连接路径时也会被加密,那么 NGINX 如何进行基于路径的路由?它是否在入口解密连接并重新加密它?另外,使用这种方法会影响性能吗?

I'm confused in terms of how exactly this happens because when we encrypt the connection path also get encrypted then how NGINX does path-based routing? does it decrypt the connection at ingress and re-encrypt it? also, does performance get affected by using this method?

推荐答案

TL;DR

它会在入口解密连接并重新加密吗?

does it decrypt the connection at ingress and re-encrypt it?

简而言之,是的.请参阅下面的说明.

In short, yes. Please see the explanation below.

请求到达Pod的路径可以看作:

The path that a request is travelling to get to a Pod can be seen as:

假设我们有一个 Ingress 控制器 (nginx-ingress) 代替了 Ingress,您可以通过多种方式连接您的客户端带有 Pod(简化):

Assuming that we have an Ingress controller (nginx-ingress) in place of an Ingress you can have several ways to connect your client with a Pod (simplified):

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆