Global http to https redirect in v2

Hi All,

Just wanted to post a solution that worked for me on k8s without having to create a "dummy" service:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: http-catchall
spec:
  entryPoints:
  - web
  routes:
  - match: HostRegexp(`{host:.+}`)
    kind: Rule
    services:
    - kind: TraefikService
      name: noop@internal
    middlewares:
    - name: https-redirect
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: https-redirect
spec:
  redirectScheme:
    scheme: https
    permanent: true

To get round the need to create a dummy service, the http-catchall ingressroute is set to point to the noop@internal service, which according to the following was "made to be used with redirect":

For reference, we're using:

  • Traefik 2.2 installed via helm
  • k8s on AWS installed via kops
  • An AWS ELB in L7 mode with TLS termination on the ELB
2 Likes