[SOLVED] Traefik IngressRoute not redirecting to "/dashboard/#/"

I have new Traefik setup with following IngressRoute & Middleware

---

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-admin
  namespace: kube-ingress
spec:
  entryPoints:
    - web
    - websecure
  routes:
    - match: Host(`traefik.domain.com`)
      kind: Rule
      services:
        - name: traefik
          port: 8080
      middlewares:
        - name: secured-restricted
  tls:
    secretName: star-domain-com

---

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: secured-restricted
  namespace: kube-ingress
spec:
  chain:
    middlewares:
    - name: https-redirect
    - name: permited-ips

---

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: https-redirect
  namespace: kube-ingress
spec:
  redirectScheme:
    scheme: https
    permanent: true

---

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: permited-ips
  namespace: kube-ingress
spec:
  ipWhiteList:
    sourceRange:
    - x.x.x.x/28

---

When I try to open any of the following in browser

  • traefik.domain.com
  • http://traefik.domain.com
  • https://traefik.domain.com

shows message 404 page not found

When I type https://traefik.domain.com/dashboard/#/ then only dashboard gets loaded.
What is wrong here ?

1 Like

Hello @rp346

here is the valid configuration for getting access to the dashboard. Please note that there is only websecure entrypoint configured and service refers to TraefikService and api@internal.

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: dashboard
spec:
  entryPoints:
    - websecure
  routes:
    - kind: Rule
      match: Host(`d.me.demo.traefiklabs.tech`)
      services:
        - kind: TraefikService
          name: api@internal
      middlewares:
        - name: default-test-auth@kubernetescrd
  tls:
    certResolver: le

Having that configuration you will be automatically redirected to the dashboard.

❯ curl -uadmin:secret https://d.me.demo.traefiklabs.tech/ -L  -i
HTTP/2 302
content-type: text/html; charset=utf-8
location: /dashboard/
content-length: 34
date: Wed, 26 May 2021 08:56:01 GMT

HTTP/2 200
accept-ranges: bytes
content-type: text/html; charset=utf-8
last-modified: Tue, 23 Mar 2021 15:48:36 GMT
content-length: 3026
date: Wed, 26 May 2021 08:56:01 GMT

Hope that helps,

This is an alternative to the Traefik specific ingressRoute objects. --entryPoints.web.address=:80 - --entryPoints.websecure.address=:443 # permanent redirecting of all So you do not need a extra middleware object.

even I have following Middleware for traefik.domain.com IngressRoute, It's not redirecting http to https.

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: https-redirect
spec:
  redirectScheme:
    scheme: https
    permanent: true

Hello @rp346

I explained in details how to correctly configured redirection from HTTP to HTTPS in one of the latest workshops I prepared. Please have a look at exercises 8,9 and 12

and here is the link to the recording: Traefik Workshop: Getting Started with Traefik - YouTube

Technically speaking you are adding the redirectscheme middleware on Ingressroute with entry point HTTP.

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: whoami-crd
spec:
  entryPoints:
    - web
  routes:
    - kind: Rule
      match: Host(`crd.<FIXME>.demo.traefiklabs.tech`)
      services:
        - kind: Service
          name: whoami-svc
          port: 80
      middlewares:
        - name: default-redirectscheme@kubernetescrd

You can also create a global redirection on entrypoint level.

I hope that helps.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.