Exclude particular path(s) from basicauth

I am wondering if it's possible to remove basic authenticaiton for a particular PathPrefix. I would like to protect all but one or two particular paths.

my configuration (using docker) is something like this:

  • traefik.http.routers.web-prod.rule=Host(my.site)
  • traefik.http.routers.web-prod.middlewares=prod-auth
  • traefik.http.middlewares.prod-auth.basicauth.users=user:pw

I can't seem to find a way to then exclude say PathPrefix(/api)

Is this even possible with traefik?

You would have to add another router on the service.

- "traefik.http.routers.first.rule=Host(`my.site`)"
- "traefik.http.routers.first.middlewares=prod-auth"
- "traefik.http.middlewares.prod-auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/'"
- "traefik.http.routers.second.rule(Host(`my.site`) && PathPrefix(`/api`))"