[SOLVED] Dashboard & API with Separate auth

I'm running into an issue with the following scenario; I'm attempting to run traefik's dashboard behind authelia (for obvious reasons), but I also want the API secured with basic auth (for other reasons). Currently I'm attempting to test this using the api and dashboard as two different routers (one tied to authelia and one tied to basic auth) but it seems that no matter what I do, when I configure the API to use basic auth it also forces the dashboard to use basic auth despite what the dashboard itself says about the configured middlewares. Ans insight into why this is the case would be very much appreciated.

http:
  routers:
    api:
      rule: "Host(`traefik.xxxxxxxxxxxxxx.com`) && PathPrefix(`/api`)"
      entrypoints:
        - web
        - websecure
      service: api@internal
      middlewares:
        - default
        - authbasic
      tls: {}

    dashboard:
      rule: "Host(`traefik.xxxxxxxxxxxxxx.com`) && PathPrefix(`/dashboard`)"
      entrypoints:
        - web
        - websecure
      service: api@internal
      middlewares:
        - default
        - authelia
      tls: {}

Expected: Two endpoints, one serving basic auth and the other serving authelia.

Observed: Two seperate endpoints. API endpoint serving basic auth as intended, Dashboard serving Authelia and basic auth.

Any help is appreciated, but if you're bringing suggestions then keep them in the realm of my requirements.

Dashboard will access /api. So as you have it you will be prompted for both authentications.

If that's the case then what's the best way to handle this? I'm not leaving the API Exposed without auth, but I'm not leaving basic auth for the dashboard in place either. There has to be a good way to address this.

Keep a rule for dashboard that has both /api and /dashboard and using authelia.

Create another router that you use with authbasic. This rule cannot conflict with the other. You'll have to work out the approach you want to take.

  • A different Host rule
  • PathPrefix & StripPrefix middleware
  • Headers or HeadersRexexp

Perfect, I figured there was a deceptively simple solution :sweat_smile:

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