Cannot get basic auth to work

I tried basic auth using docker-compose with just the labels and with grafana.
Just the labels:

      # traefik.enable: true
      # traefik.frontend.rule: ""
      # get md5 from htpasswd or
      # and then double all $ to $$ to avoid docker-compose 
      - "traefik.http.middlewares.test-auth.basicauth.users=admin:$$apr1$$0QjLF.3T$$tfscnZS/gpLPH.aKD5lEV0"
      - "traefik.http.middlewares.test-auth.basicauth.realm=traefik"
      - ""
      - "traefik.http.middlewares.test-auth.basicauth.removeheader=true"

With grafana:

    image: grafana/grafana:6.6.0 
      traefik.enable: true

      # HTTP (LAN) connection
      traefik.http.routers.grafana_lan.rule: Host(``) && PathPrefix(`/grafana`)
      traefik.http.routers.grafana_lan.entrypoints: web
      traefik.http.routers.grafana_lan.middlewares: grafana_auth,strip_grafana_prefix
      # HTTPS (WAN) connection
      # traefik.http.routers.grafana_wan.rule: Host(`wan.localhost`) && PathPrefix(`/grafana`)
      # traefik.http.routers.grafana_wan.entrypoints: websecure
      # traefik.http.routers.grafana_wan.tls: true
      # traefik.http.routers.grafana_wan.middlewares: grafana_auth,strip_grafana_prefix
      # Tell Traefik to use the port grafana to connect to `my-container` 3000
      # middlewares
      traefik.http.middlewares.grafana_auth.basicauth.users: admin:$$apr1$$0QjLF.3T$$tfscnZS/gpLPH.aKD5lEV0 # user/password
      traefik.http.middlewares.grafana_auth.basicauth.removeheader: true
      traefik.http.middlewares.strip_grafana_prefix.stripprefix.prefixes: /grafana


Both show up in the HTTP middleware as success with the hashed user:password.

But there's no pop up coming to login or use password, everyone can see the page.

How can I fix this?

Hi @kenjibailly

this is working fine for me :

      - "traefik.http.routers.grafana.middlewares=grafana_auth"
      - "traefik.http.middlewares.grafana_auth.basicauth.users=admin:$$apr1$$0QjLF.3T$$tfscnZS/gpLPH.aKD5lEV0"
      - "traefik.http.middlewares.grafana_auth.basicauth.removeheader=true"

Maybe a question of quote mark (there is a lots of special signs in the hash) ?

Hope this helps

I tried it, but no difference at all unfortunately.
I tried the put the quotes in different positions, but also no difference.

Le 3 last lines are the only things i added to my grafana conf to test your problem :

            - "traefik.enable=true"
            - "traefik.http.routers.grafana.rule=Host(`"
            - "traefik.http.routers.grafana.entrypoints=https"
            - "traefik.http.routers.grafana.tls.certresolver=cloudflare"
            - "[0]"
            - ""
            - "traefik.http.routers.grafana.middlewares=grafana_auth"
            - "traefik.http.middlewares.grafana_auth.basicauth.users=admin:$$apr1$$0QjLF.3T$$tfscnZS/gpLPH.aKD5lEV0"
            - "traefik.http.middlewares.grafana_auth.basicauth.removeheader=true"

the only difference seems to be the "stripprefix" middleware, have you tried without (with a subdomain) ?

Have you worked out the problem? I am having the same at the moment

My medical situation got worse again and didn't find the courage to try out the solution.
Then I kinda forgot about it and found out about easy basic auth in nginx proxy manager and I'm running with that now.
It's just a setting and nothing more, so I didn't bother anymore.

I'm sorry to those who made efforts, I also need to study more about traefik because I don't really understand how it works yet.

Hi @kenjibailly , sorry to hear about your health. I hope you are getting better. If you do not mind could you share how you have used nginx proxy manager as I tried that one too but again failed to achieve a setting with working SSL