Nerdieworks / nerdieworks.nl

Hugo website for https://nerdieworks.nl
0 stars 0 forks source link

posts/traefik-default-http-to-https-redirect/ #1

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Traefik: default HTTP to HTTPS redirect • Nerdieworks

When using Traefik as your Kubernetes ingress controller you would probably want a default HTTP to HTTPS redirect. You can use this snippet to create a Traefik IngressRoute and Traefik Middleware that will do just that. Prerequisites A running instance of Traefik v2 in a Kubernetes cluster kubectl access to the Kubernetes cluster External IP address of the server/VM for testing Snippet apiVersion: traefik.containo.us/v1alpha1 kind: IngressRoute metadata: name: http-to-https-redirect namespace: traefik spec: entryPoints: - web # Change this?

https://nerdieworks.nl/posts/traefik-default-http-to-https-redirect/

mauvm commented 2 years ago

Test comment. Hello person that reads this 👋

david618 commented 1 year ago

This was just what I needed to get http to https working for our ingress points.

I created the IngressRoute and MiddleWare as you specified above.

One extra step I found that I needed was to add an annotation to the Ingress.

traefik.ingress.kubernetes.io/router.entrypoints: websecure 

Once I did that https worked and if I tried to access via http I was redirected to https.

Thanks for creating your post.