TRAEFIK v2 (Part 2)

HTTP HTTPS redirect with Traefik v2

Once you have setup Traefik running in your Kubernetes cluster, you might want to configure additional thing like http to https redirect. For more information about the Traefik setup check part 1. More information about routing entryPoints can be found on the Traefik official website:

If you would like to redirect all http traffic to https you easily do this in the values.yaml file we’ve used in part 1 in the Configure ports section. In this section you see two entrypoints web and websecure. To redirect all traffic from web to websecure simply add redirectTo: websecure in the web section of the values.yaml.

# Configure ports
    port: 8000
    expose: true
    exposedPort: 80
    protocol: TCP
    redirectTo: websecure
    port: 4443
    expose: true
    exposedPort: 443
    protocol: TCP

After updating the values.yaml you have to update the helm deployment:

helm upgrade --namespace=traefik --values=values.yaml traefik traefik/traefik

After the update the entryPoint for the IngressRoute needs to be updated, as the old configuration has the entryPoint web defined, instead of websecure. Apply the updated IngressRoute by:

kubectl apply -f ingressroute.yaml

kind: IngressRoute
  name: ingress-app1
  namespace: app1
    - websecure
  - match: Host(``)
    kind: Rule
    - name: app1-service
      port: 80

After applying the new IngressRoute all http traffic will redirect to https.

1 thought on “TRAEFIK v2 (Part 2)

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll Up