Traefik ingress annotation "redirect http to https" redirecting to another website

Hello everyone,

I'm using Traefik as a ingress for K8S and when I try to redirect with annotations http to https for some reason another website that is being hosted by the same K8S...

My ingress yaml:

kind: Ingress
  namespace: prod
  name: client-ead
  annotations: traefik "true" "true" http,https "true" https
  - hosts:
    secretName: tlssecret
      - backend:
            name: client-ead
              number: 80
        path: /
        pathType: Prefix

The fun part is that I have another client hosted and when the redirect is applyed, the redirects to BUT if I type address with https it goes fine (

Note that I have the 2 tls secrets in my K8S.

Am I doing something wrong?

Thx in advance

I had the same problem. At the end found out 2 solutions.

The first one is activate the redirect globally. That can be done by uncommenting:

redirectTo: websecure

In my case, I had to uncomment it in my Traefik's "values.yaml" helmchart. So you need to look at your Traefik config, in order to check this one out.

The second solution would be defining two ingresses, one for http and the other one for https. And then you need a "RedirectScheme" Middleware in order to pass the http requests to https.

Since the second one is a bit awkward, I went with the global definition in Traefik configuration.

Hope this helps.

1 Like