Search code examples
dockeramazon-elbtraefik

traefik v2 dashboard basic auth not working behind AWS elb


I have my traefik v2 setup and when i try to access the dashboard which is behind AWS elb, the basic auth doe not work. But the same configu works when i hit traefik directly

here is what my config looks like

version: '3.5'

services:
  traefik:
    image: traefik:v2.2
    container_name: traefik
    restart: always
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
    networks:
      - traefik_network
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
       - "traefik.enable=true"
       - "traefik.docker.network=traefik_network"       
       - "traefik.http.services.traefik.loadbalancer.server.port=8080"
       - "traefik.http.routers.traefik.rule=Host(`traefik.local.host`)"
       - "traefik.http.routers.traefik.middlewares=traefik"
       - "traefik.http.middlewares.traefik.basicauth.users=test:$$apr1$$1pmerTx$$qsMzjTuYTHyEn12LKmteghC."
       - "traefik.http.middlewares.traefik.basicauth.removeheader=true"

networks:
  traefik_network:
     name: traefik_network

What do i need to do to have basic auth work for the traefik v2 dashboard when am behind AWS elb???


Solution

  • Issue was me, all looks good but i needed to use port 80, not 8080!!!

    version: '3.5'
    
    services:
      traefik:
        image: traefik:v2.2
        container_name: traefik
        restart: always
        command:
          - "--api.insecure=true"
          - "--providers.docker=true"
        networks:
          - traefik_network
        ports:
          - "80:80"
          - "8080:8080"
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock
        labels:
           - "traefik.enable=true"
           - "traefik.docker.network=traefik_network"       
           - "traefik.http.services.traefik.loadbalancer.server.port=80"
           - "traefik.http.routers.traefik.rule=Host(`traefik.local.host`)"
           - "traefik.http.routers.traefik.middlewares=traefik"
           - "traefik.http.middlewares.traefik.basicauth.users=test:$$apr1$$1pmerTx$$qsMzjTuYTHyEn12LKmteghC."
           - "traefik.http.middlewares.traefik.basicauth.removeheader=true"
    
    networks:
      traefik_network:
         name: traefik_network