Skip to content

HTTP > HTTPS not working with NLB with TLS termination and Proxy Protocol V2Β #1209

@sgasquet

Description

@sgasquet

Describe the bug
Hi there.
We are facing a weird issue regarding HTTPS redirection with this ingress on this context:

  • Load-Balancer : NLB with TLS termination / Certificate in AWS cert manager
  • Deployment via HELM Chart
  • ProxyProtocol V2 enable in chart and target groups

To Reproduce
Our configuration in values.yaml file :

 controller:
    kind: daemonset
    config:
      entries:
        hsts: "True"
        proxy-protocol: "True"
        real-ip-header: proxy_protocol
        redirect-to-https: "True"
        server-tokens: "False"
        set-real-ip-from: 0.0.0.0/0
    service:
      type: LoadBalancer
      externalTrafficPolicy: Cluster
      annotations:
        service.beta.kubernetes.io/aws-load-balancer-type: nlb
        service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: "*"
        service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
        service.beta.kubernetes.io/aws-load-balancer-ssl-cert-ports: https
        service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
        service.beta.kubernetes.io/aws-load-balancer-ssl-negotiation-policy: "ELBSecurityPolicy-TLS-1-2-2017-01"
        service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:xxxxxxxxxxxxxxxxxx
      httpPort:
        enable: true
        port: 80
        targetPort: http
      httpsPort:
        enable: true
        port: 443
        targetPort: http

Expected behavior
In ingress of a web backend application, HTTPS redirect should occur with this kind of annotations :
nginx.org/redirect-to-https
ingress.kubernetes.io/ssl-redirect: "True"
But none of this works actually.

Debug
To debug this behavior, we played with tcpdump inside a POD and see what Headers are saw.
First thing, the header X-FORWARDED-PROTO is always the same, reaching the endpoint in HTTP or HTTPS won't change that. And still no redirection is done.
Here are the headers we can see :
X-Real-IP: X.X.X.X OK
X-Forwarded-For: X.X.X.X OK
X-Forwarded-Host: host.blabla OK
X-Forwarded-Port: 80 (always)
X-Forwarded-Proto: HTTPS (always)

So all forwarded headers are good but not X-Forwarded-Port and X-Forwarded-Proto which never change.

Is anything we are doing wrong in the configuration ? Is it related to the ProxyProtocol which forwards the protocol defined here "aws-load-balancer-backend-protocol: http" and not the real protocol used by client ?
Any help appreciated :)

Thanks for your help !

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationPull requests/issues for documentationenhancementPull requests for new features/feature enhancementsstalePull requests/issues with no activity

    Type

    No type

    Projects

    Status

    Done πŸš€

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions