【问题标题】:Access spring security through kubernetes ingress通过 Kubernetes Ingress 访问 Spring Security
【发布时间】:2020-12-20 13:58:13
【问题描述】:

我在后端启用了 tls。所以每一次流量都需要经过“https://.....”。 我可以在本地访问它,也可以在 Kubernetes 中使用端口转发。 但我无法通过 DNS 访问它(例如https://hostname.net/backend/....)。

我得到答案:

Bad Request
This combination of host and port requires TLS.

我读到证书可能是错误的,但是通过端口转发一切正常,所以我认为这不是问题。证书是自签名的。我只有我的服务器证书。

在我添加 tls 之前,everythinkg 工作正常。

这是我的服务和入口:

apiVersion: v1
kind: Service
metadata:
  name: app-Core
  namespace: namespace
spec:
  clusterIP: xxx.xxx.xxx.xxx
  ports:
  - name: http
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/instance: core
    app.kubernetes.io/name: app
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
----------------------------------
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: core-app-core
  namespace: namespace
spec:
  rules:
  - host: hostname
    http:
      paths:
      - backend:
          serviceName: app-Core
          servicePort: 8080
        path: /backend(/|$)(.*)
      - backend:
          serviceName: app-Core
          servicePort: 8080
        path: /camunda(/|$)(.*)
status:
  loadBalancer:
    ingress:
    - ip: xxx.xxx.xxx.xxx


【问题讨论】:

标签: kubernetes kubernetes-ingress kubernetes-service kubernetes-security


【解决方案1】:

尝试将 nginx.ingress.kubernetes.io/backend-protocol: https 注释添加到您的入口定义中。

使用backend-protocol 注释可以指示NGINX 应该如何与后端服务通信。 默认情况下,NGINX 使用HTTP

看看:ingress-tls,backend-protocol

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-06
    • 2021-02-02
    • 2019-07-21
    • 2021-06-23
    • 1970-01-01
    • 2020-02-25
    • 2019-02-18
    相关资源
    最近更新 更多