簡體   English   中英

僅強制 Kubernetes Nginx 入口上的 HTTPs 流量

[英]Force only HTTPs Traffic on Kubernetes Nginx Ingress

我正在嘗試禁用特定 API 的所有 HTTP 入口流量。 在添加此注釋kubernetes.io/ingress.allow-http: "false"后,我嘗試刪除入口並重新創建,但這也不起作用。 我仍然可以點擊 API 並在 http://<ingress-dns-name/shipping-address/api 上獲得響應

  • Both Nginx Controller and the API are deployed of course on the same azure Kubernetes cluster.
  • 在默認命名空間中創建了一個秘密my-tls-secret
  • Nginx controller 有自己的命名空間

這是入口 yaml 文件:

kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.allow-http: "false"
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  generation: 1
  labels:
    app.kubernetes.io/managed-by: Helm
  name: api-shipping-address-ingress
  namespace: nonprod-dev
  resourceVersion: "31734103"
  uid: c9a698a0-3d2e-4f3b-99a9-c16c6fa83774
spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: api-shipping-address
            port:
              number: 3000
        path: /shipping-address(/|$)(.*)
        pathType: ImplementationSpecific
  tls:
  - secretName: my-tls-secret
status:
  loadBalancer:
    ingress:
    - ip: 10.86.168.200

我遇到了同樣的問題並通過添加nginx.ingress.kubernetes.io/force-ssl-redirect: "true"來解決它,如ingress-nginx 文檔中所述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM