How to use ingress-nginx with secure backend?

Hi, I am using ingress-nginx for making kibana accessible from outside the cluster.
I have the task to completely encrypt the application, so I think I need the following chain

Browser -> TLS -> ingress-nginx -> TLS -> service (kibana).
Kibana will also use tls encryption to connect elasticsearch, which is working fine so far.

I am at this point now:

  • using insecure ingress-nginx (http) with an insecure backend (http) -> OK
  • using secure ingress-nginx(https) with an insecure backend (http) -> OK
  • using secureingress-nginx (https) with secure backend (https) -> FAILS

here is my ingress configuration:

kind: Ingress
  name: test-ingress
    cluster: test
    app: kibana
    product: elasticStack
  # /test-kibana
  # enable to use secure backend "true"
  - hosts:
    secretName: elastic.ingress.kubernetes-tls
  - host: elastic.ingress.kubernetes
      - path: /test-kibana
          serviceName: test-kibana
          servicePort: 5601

When I call the ingress url in browser with https, I get 502 bad gateway.

Log of ingress pods are showing this:

2019/07/30 08:16:17 [error] 44#44: *59001 upstream prematurely closed connection while reading response header from upstream, client:, server:, request: "GET /test-kibana/ HTTP/2.0", upstream: "", host: ""

As you can see, it is forwarded to http, not https.

In kibana’s log I see following error:

{"type":"error","@timestamp":"2019-07-30T08:16:17Z","tags":["connection","client","error"],"pid":1,"level":"error","error":{"message":"139688227514240:error:1408F09C:SSL routines:ssl3_get_record:http request:../deps/openssl/openssl/ssl/record/ssl3_record.c:242:\n","name":"Error","stack":"Error: 139688227514240:error:1408F09C:SSL routines:ssl3_get_record:http request:../deps/openssl/openssl/ssl/record/ssl3_record.c:242:\n"},"message":"139688227514240:error:1408F09C:SSL routines:ssl3_get_record:http request:../deps/openssl/openssl/ssl/record/ssl3_record.c:242:\n"}

That is the identical error message as if i call the service via curl with http:
kubectl exec -it test-es-master-0 -- curl -k -L http://test-kibana:5601/test-kibana
instead of https:
kubectl exec -it test-es-master-0 -- curl -k -L https://test-kibana:5601/test-kibana

https from inside a pod against the service is working like charm.

So what do I need to change to use a secure backend via tls?

Thanks, Andreas

found the solution. I added a second annotation: "HTTPS"

That made the trick

1 Like

Great, thanks for sharing :slight_smile: