HTTPS Redirects with Traefik in Kubernetes
1 min read

HTTPS Redirects with Traefik in Kubernetes

Lots of documentation shows that an `ingress.kubernetes.io/ssl-redirect: "true"` ingress annotation is the proper way to do an HTTPS redirect in Kubernetes. I'm not sure if it ever worked, but it certainly doesn't now. Use Traefik middleware instead:

---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: https-redirect
  namespace: [namespace]
spec:
  redirectScheme:
    scheme: https
    permanent: true
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  ...
  namespace: [namespace]
  annotations:
    ...
    traefik.ingress.kubernetes.io/router.middlewares: [namespace]-https-redirect@kubernetescrd