Basic auth and file provider

Hi,

I am running Traefik 2.4.8 and have both Docker and File providers configured. Testing with basic auth with one of my file providers/hosts but doesn't work (no basic auth dialog appears)

http:
  routers:
    custom:
      rule: Host(`sub.mydomain.com`)
      service: custom
      tls:
        certresolver: le

  services:
    custom:
      loadBalancer:
        servers:
          - url: http://192.168.1.100:80

  middlewares:
    custom:
      basicAuth:
        users:
          - test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/

Do I need to enable something else to make it work?

Hi @4integration

You have defined the middleware but your router(s) are not using it.

add middlewares: basicAuth middlewares: custom to your router, if you are going to add it to docker routers use basicAuth@file as the middleware- name.

edit: middleware name

1 Like

Thanks @cakiwi
That solved it - with a minor correction (whick I think is correct)

middlewares: custom
to the router

http:
  routers:
    custom:
      rule: Host(`sub.domain.com`)
      service: custom
      middlewares: custom
      tls:
        certresolver: le

  services:
    custom:
      loadBalancer:
        servers:
          - url: http://192.168.1.100:80

  middlewares:
    custom:
      basicAuth:
        users:
          - test:$apr1$gtoijc1b$PdK1IzIA.fuL6aQRyrqK4/
1 Like

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