如果https流量,如何转发到ssl端口(443)

时间:2019-05-17 13:25:26

标签: kubernetes kubernetes-ingress nginx-ingress

入口如何将https流量转发到服务的端口443(最终到我的容器上的8443)?我必须对入口进行任何更改还是自动完成。

在GCP上,我有第4层平衡器-> nginx入口控制器->入口

我的入口是:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-keycloak
  annotations:
    kubernetes.io/ingress.class: "nginx"
    certmanager.k8s.io/issuer: "letsencrypt-prod"
    certmanager.k8s.io/acme-challenge-type: http01


spec:
  tls:
  - hosts:
    - mysite.com
    secretName: staging-iam-tls
  rules:
  - host: mysite.com
    http:
      paths:
      - path: /auth
        backend:
          serviceName: keycloak-http
          servicePort: 80

我在网上搜索,但没有看到显示达到443的明确示例。始终为80(或8080)

我的服务keycloak-http被删除(并且我的容器实际上正在侦听8443)

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: 2019-05-15T12:45:58Z
  labels:
    app: keycloak
    chart: keycloak-4.12.0
    heritage: Tiller
    release: keycloak
  name: keycloak-http
  namespace: default
 ..
spec:
  clusterIP: ..
  externalTrafficPolicy: Cluster
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: http
  - name: https
    port: 443
    protocol: TCP
    targetPort: 8443
  selector:
    app: keycloak
    release: keycloak
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}

1 个答案:

答案 0 :(得分:0)

尝试一下:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-keycloak
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    certmanager.k8s.io/issuer: "letsencrypt-prod"
    certmanager.k8s.io/acme-challenge-type: http01
spec:
  tls:
  - hosts:
    - mysite.com
    secretName: staging-iam-tls
  rules:
  - host: mysite.com
    http:
      paths:
      - path: /auth
        backend:
          serviceName: keycloak-http
          servicePort: 443