I am using Docker with a cookiecutter Django boilerplate. The first time I use Traefik and I like it so far! However I am trying to add basic auth to the whole website, but I can't seem to make it work.
My traefik.yml file:
log: level: INFO entryPoints: web: # http address: ":80" web-secure: # https address: ":443" certificatesResolvers: letsencrypt: # https://docs.traefik.io/master/https/acme/#lets-encrypt acme: email: "email@example.com" storage: /etc/traefik/acme/acme.json # https://docs.traefik.io/master/https/acme/#httpchallenge httpChallenge: entryPoint: web http: routers: web-router: rule: "Host(`domain.com`) || Host(`www.domain.com`)" entryPoints: - web middlewares: - myod-auth - redirect - csrf service: django web-secure-router: rule: "Host(`domain.com`) || Host(`www.domain.com`)" entryPoints: - web-secure middlewares: - myod-auth - csrf service: django tls: # https://docs.traefik.io/master/routing/routers/#certresolver certResolver: letsencrypt middlewares: myod-auth: basicAuth: users: - "name:$apr1$TgZodRDgjksd892DD3gI/t0" redirect: # https://docs.traefik.io/master/middlewares/redirectscheme/ redirectScheme: scheme: https permanent: true csrf: # https://docs.traefik.io/master/middlewares/headers/#hostsproxyheaders # https://docs.djangoproject.com/en/dev/ref/csrf/#ajax headers: hostsProxyHeaders: ["X-CSRFToken"] services: django: loadBalancer: servers: - url: http://django:5000 providers: # https://docs.traefik.io/master/providers/file/ file: filename: /etc/traefik/traefik.yml watch: true
I added the Basic auth as middleware so it should work right?