Enable auth based traefik dashboard

I am pretty new playing around traefik. I want to enable auth based traefik dashboard but I am no where close to it.

traefik.toml

[api]
  dashboard = true

[entryPoints]
  [entryPoints.dashboard]
    address = ":8443"

[http.routers.api]
  rule = "PathPrefix(`/dashboard`))"
  entryPoints = ["dashboard"]
  service = "api@internal"
  middlewares = ["auth"]

[http.middlewares.auth.basicauth]
  users = [
    "user:passwd",
  ]

I tried things around entrypoints and routers but couldn't get it working, page simply returns 404.

You are mixing you dynamic and static configuration in the same file. You will need to split them up.

https://doc.traefik.io/traefik/getting-started/configuration-overview/

I moved out my router config to dynamic configuration file but I still get 404

traefik.toml

[api]
  dashboard = true

[entryPoints]
  [entryPoints.dashboard]
    address = ":8443"

[providers.file]
  filename = "/etc/traefik-dy.toml"

traefik-dy.toml

[http]
  [http.routers.api]
    rule = "(PathPrefix(`/dashboard`))"
    entryPoints = ["dashboard"]
    service = "api@internal"
    middlewares = ["auth"]

  [http.middlewares]
    [http.middlewares.auth.basicauth]
      users = [
        "user:passwd",
      ]

What url are you using? The dashboard url has to end in / to load correclty.

i.e. http://example.com/dashboard/

yes I am ending the URL correctly with /

http://domain:8443/dashboard/

You're missing rules for the /api endpoint too, they are both required for the dashboard.

https://doc.traefik.io/traefik/operations/dashboard/#dashboard-router-rule