Search code examples
kuberneteskubernetes-helmkubernetes-ingressnginx-ingress

Trouble setting up secure connection for ingress behind ingress - bad gateway


I'm trying to set up a connection to a kubernetes cluster and I'm getting a 502 bad gateway error.

The cluster has an nginx ingress and a service (listening at both http and https). In addition the ingress is behind an nginx ingress service (I have nginx helm chart installed) with a static IP address.

I can see in the description of the cluster ingress that it knows the service's endpoints. I see that the pods communicate successfully with each other (there are 3 pods), but I can't ping the external nginx from within a shell.

These are the cluster's ingress values in values.yaml:

  ingress:
    # If `true`, an Ingress is created
    enabled: true
    # The Service port targeted by the Ingress
    servicePort: http
    # Ingress annotations
    annotations:
      kubernetes.io/ingress.class: "nginx"
    # Additional Ingress labels
    labels: {}
      # List of rules for the Ingress
    rules:
      -
        # Ingress host
        host: my-app.com
        # Paths for the host
        paths:
          - /
    # TLS configuration
    tls:
      - hosts:
          - my-app.com
        secretName: my-app-tls

When I go to my-app.com I see in the browser that I'm on a secure connection (the lock icon next to the URL), but like I said I get a 502 bad gateway error. If I replace the servicePort from http to https I get the '400 bad request' error.

How should I set up both ingresses to allow a secured connection to my app? I tried all sorts of annotations, but always got the errors above.

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

Thank you!


Solution

  • The missing annotation was nginx.org/ssl-services, which accepts the list of secure services.