# HTTP to HTTPS redirect

**URL:** <https://community.traefik.io/t/http-to-https-redirect/7277>\
**Category:** Traefik v2\
**Tags:** kubernetes-ingress\
**Created:** [August 12, 2020, 9:19am UTC](https://community.traefik.io/t/http-to-https-redirect/7277 "2020-08-12T09:19:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudobhat](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sudobhat](https://community.traefik.io/u/sudobhat)\
**Post date:** [August 12, 2020, 9:19am UTC](https://community.traefik.io/t/http-to-https-redirect/7277/1 "2020-08-12T09:19:48Z")

</div>

Using kubernetes traefik (2) ingerssroute, I am having problems redirecting from HTTP to HTTPS.

I am using this middleware:

```auto
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: traefik-middleware-redirectscheme
  namespace: default
spec:
  redirectScheme:
    scheme: https
    permanent: true

```

Using the above middleware in ingressroute for all the defined routes.

But, when I go to [http://my-server-dns](http://my-server-dns), I am not redirected to [https://my-server-dns](https://my-server-dns).  
Instead [http://my-server-dns](http://my-server-dns) resturns 404

is there any more configuration necessary? Kindly help

---

<div class="post-metadata">

**Author:** ![SantoDE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/santode/32/393_2.png) [@SantoDE](https://community.traefik.io/u/SantoDE)\
**Post date:** [August 12, 2020, 2:54pm UTC](https://community.traefik.io/t/http-to-https-redirect/7277/2 "2020-08-12T14:54:20Z")

</div>

On which IngressRoutes do you add this middleware?

---

<div class="post-metadata">

**Author:** ![sudobhat](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sudobhat](https://community.traefik.io/u/sudobhat)\
**Post date:** [August 13, 2020, 7:36am UTC](https://community.traefik.io/t/http-to-https-redirect/7277/3 "2020-08-13T07:36:33Z")

</div>

> [@sudobhat](#):
>

I added it for all the routes something like this (one of the routes shown)

```auto
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  annotations:
    kubernetes.io/ingress.class: traefik
  name: traefik-ingressroute
  namespace: default
spec:
  entryPoints:
    - web
    - websecure
  routes:
    - kind: Rule
      match: Host(`my-dns-name`) && PathPrefix(`/path`, `/path/`)
      middlewares:
        - name: traefik-middleware-headers
          namespace: default
        - name: traefik-middleware-redirectscheme
          namespace: default
      services:
        - kind: Service
          name: service-name
          namespace: default
          port: <PORT>
    - kind: Rule
    .......................

  tls:
    secretName: ca-key-pair

```

---

<div class="post-metadata">

**Author:** ![SantoDE](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/santode/32/393_2.png) [@SantoDE](https://community.traefik.io/u/SantoDE)\
**Post date:** [August 13, 2020, 12:19pm UTC](https://community.traefik.io/t/http-to-https-redirect/7277/4 "2020-08-13T12:19:59Z")

</div>

You cant use the `IngressRoute` like that. If you have an `IngressRoute` with a TLS section, attach that to the `websecure` entrypoint. Then, have the "same" Ressource but without the `tls` section and attached to the `web` entrypoint. Then your 404 should be resolved.

---

<div class="post-metadata">

**Author:** ![sudobhat](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sudobhat](https://community.traefik.io/u/sudobhat)\
**Post date:** [August 13, 2020, 12:45pm UTC](https://community.traefik.io/t/http-to-https-redirect/7277/5 "2020-08-13T12:45:19Z")

</div>

Works like a charm! Thanks for the solution
