Exclude particular path from basicauth doesn't work

I would like to remove basic authenticaiton for a particular PathPrefix. I would like to protect all but one particular path should be without auth pass. My configuration which it doesn't properly.

  - "traefik.enable=true"
  - "traefik.frontend.rule=Host:${HOST}"
  - "traefik.docker.network=traefik"
  - "traefik.http.routers.apache-${PROJECT_NAME}.entrypoints=web"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.entrypoints=websecure"
  - "traefik.http.routers.apache-${PROJECT_NAME}.tls=false"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.tls=true"
  - "traefik.http.routers.apache-${PROJECT_NAME}.rule=Host(`${HOST}`)"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.rule=Host(`${HOST}`)"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.tls.certresolver=letsencrypt"
  - "traefik.http.routers.apache-${PROJECT_NAME}.middlewares=${T2_WEB_MIDDLEWARES}"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.middlewares=${T2_WEBSECURE_MIDDLEWARES}"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.priority=100"
  - "traefik.http.middlewares.${PROJECT_NAME}-authpass.basicauth.users=${T2_AUTH_WEB}"
  - "traefik.http.routers.apache-${PROJECT_NAME}-api.rule=(Host(`${HOST}`) && PathPrefix(`/methoden`))"
  - "traefik.http.routers.apache-${PROJECT_NAME}-api.entrypoints=websecure"
  - "traefik.http.routers.apache-${PROJECT_NAME}-api.tls=true"
  - "traefik.http.routers.apache-${PROJECT_NAME}-api.priority=101"

I think this is Traefik v1 :wink:

  - "traefik.frontend.rule=Host:${HOST}"

Grouping by router makes it easier to understand

  - "traefik.http.routers.apache-${PROJECT_NAME}.entrypoints=web"
  - "traefik.http.routers.apache-${PROJECT_NAME}.tls=false"
  - "traefik.http.routers.apache-${PROJECT_NAME}.rule=Host(`${HOST}`)"
  - "traefik.http.routers.apache-${PROJECT_NAME}.middlewares=${T2_WEB_MIDDLEWARES}"

  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.entrypoints=websecure"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.tls=true"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.rule=Host(`${HOST}`)"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.tls.certresolver=letsencrypt"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.middlewares=${T2_WEBSECURE_MIDDLEWARES}"
  - "traefik.http.routers.apache-${PROJECT_NAME}-websecure.priority=100"

  - "traefik.http.routers.apache-${PROJECT_NAME}-api.rule=(Host(`${HOST}`) && PathPrefix(`/methoden`))"
  - "traefik.http.routers.apache-${PROJECT_NAME}-api.entrypoints=websecure"
  - "traefik.http.routers.apache-${PROJECT_NAME}-api.tls=true"
  - "traefik.http.routers.apache-${PROJECT_NAME}-api.priority=101"

  - "traefik.http.middlewares.${PROJECT_NAME}-authpass.basicauth.users=${T2_AUTH_WEB}"

By itself the api router should have a higher priority because the rule is longer (has more characters).

You are using different TLS setups on websecure and api, is that on purpose?

I usually recommend to do http-to-https redirect and TLS assignment globally on entrypoint, that avoids repetition. See simple Traefik example.

A higher priority didn\t solve the issue. I have already tested with it before.