同一主机 nginxinc kubernetes ingress 的多个 TLS 证书

Several TLS certs for the same host nginxinc kubernetes ingress

我正在玩 k8s 和 Nginx 入口控制器
(https://docs.nginx.com/nginx-ingress-controller/).

我有一个主机名 test.example.com,它使用为相同名称签名的两个证书(RSA 和 GOST)处理 HTTPS 连接。

是否有使用 Nginx Ingress 终止这些 TLS 连接的正确方法?还是我最好使用外部负载平衡器?

首先弄清楚 terminating 是什么:

SSL termination refers to the process of decrypting encrypted traffic before passing it along to a web server.

除了你提到的还有其他方法,比如使用外部 LoadBalancer 但正弦 Nginx 是一个 LoadBalancer 没有必要添加另一个外部 LoadBalancer

保持简单

  • 保持简单,从长远来看,您遇到的问题会更少 运行。
  • 使用 nginx-controller 是完成它的合适方法。
  • 添加更多“工具”将需要您维护它们,这会增加复杂性。


所以,答案实际上在 GitHub 页面的讨论中 https://github.com/nginxinc/kubernetes-ingress/issues/1899#issuecomment-905952871

没有直接支持,但可以尝试使用服务器代码段的解决方法:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: cafe-ingress
  annotations:
    nginx.org/server-snippets: |
      ssl_certificate /etc/nginx/secrets/default-second-cafe-secret; # namespace-name
      ssl_certificate_key /etc/nginx/secrets/default-second-cafe-secret; # namespace-name
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - cafe.example.com
    secretName: cafe-secret
  - hosts: # this part is needed so that the IC gets the second-cafe-secret from k8s API and store it on the file system at /etc/nginx/secrets/namespace-name
    - random-workaround-host 
    secretName: second-cafe-secret
  rules:
  - host: cafe.example.com