Attach 2 middlewares to the router?

Hi
when i attach 2 middlewares to the router only last one is effect !
also in dashboard show only last one middleware

version: "3.7"
services:
  traefik:
    image: traefik:v2.0
    container_name: reverse-proxy
    command: 
       - --api.insecure=true 
       - --providers.docker
       - --providers.docker.exposedByDefault=false 
       - --providers.docker.swarmMode=false
       - --entrypoints.web.address=:80
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime:ro
      - /data/traefik/users:/users
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.rule=Host(`traefik.mylaptop.com`)"
      - "traefik.http.middlewares.traefik-auth.basicauth.usersfile=/users"
      - "traefik.http.routers.traefik.middlewares=traefik-auth"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.entrypoints=web"

  portainer:
    image: portainer/portainer:latest
    container_name: portainer
    environment:
      - PUID=1000
      - PGID=1001
      - TZ=Asia/Riyadh
    restart: always
    command: --no-auth
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /data/portainer:/data
    labels: 
      - "traefik.enable=true"
      - "traefik.http.middlewares.portainer-stripprefix.stripprefix.prefixes=/portainer"
      - "traefik.http.middlewares.portainer-auth.basicauth.usersfile=/users"
      - "traefik.http.routers.portainer.entrypoints=web"
      - "traefik.http.routers.portainer.rule=Host(`mylaptop.com`) && PathPrefix(`/portainer`)"
      - "traefik.http.routers.portainer.middlewares=portainer-auth"
      - "traefik.http.routers.portainer.middlewares=portainer-stripprefix"
      - "traefik.http.services.portainer.loadbalancer.server.port=9000"

Hello,

the syntax to apply multiple middleware is the following:

- "traefik.http.routers.portainer.middlewares=portainer-auth,portainer-stripprefix"

The Docker labels are a map (in Docker) so the keys must be unique.

1 Like