Traefik with lots of routes in one docker service

Hello traefik community,

I'm getting the following error when I use my attached docker-compose file.

time="2021-01-10T14:28:28Z" level=error msg="Could not define the service name for the router: too many services" providerName=docker routerName=emqx-http

When I remove for example the websocket config than the redirect from http to https is working. If everything is defined traefik remove http or like I assume the oldest defined route.

  emqx:
    image: emqx/emqx:latest
    container_name: emqx
    restart: unless-stopped
    environment: 
      - EMQX_LOADED_PLUGINS="emqx_recon,emqx_retainer,emqx_management,emqx_dashboard,,emqx_prometheus,emqx_statsd,emqx_auth_mongo"
      - EMQX_ALLOW_ANONYMOUS=false
      - EMQX_PROMETHEUS__PUSH__GATEWAY__SERVER=http://pushgateway:9091
      - EMQX_PROMETHEUS__INTERVAL=1500
      - EMQX_PUSH__GATEWAY__SERVER=http://pushgateway:9091
      - EMQX_INTERVAL=1500
      - EMQX_LOG__TO=both
      - EMQX_LOG__DIR=log
      - EMQX_LOG__FILE=emqx.log
      - EMQX_LOG__LEVEL=debug
      - EMQX_AUTH__MONGO__TYPE=single
      - EMQX_AUTH__MONGO__SERVER=mongodb:27017
      - EMQX_AUTH__MONGO__POOL=8
      - EMQX_AUTH__MONGO__LOGIN=mqtt
      - EMQX_AUTH__MONGO__PASSWORD=mqtt
      - EMQX_AUTH__MONGO__DATABASE=mqtt
      - EMQX_AUTH__MONGO__QUERY_TIMEOUT=5S
      - EMQX_AUTH__MONGO__TOPOLOGY__POOL_SIZE=1
      - EMQX_AUTH__MONGO__TOPOLOGY__MAX_OVERFLOW=0
      - EMQX_AUTH__MONGO__AUTH_QUERY__PASSWORD_HASH=sha256
      - EMQX_AUTH__MONGO__AUTH_QUERY__COLLECTION=mqtt_user
      - EMQX_AUTH__MONGO__AUTH_QUERY__PASSWORD_FIELD=password
      - EMQX_AUTH__MONGO__AUTH_QUERY__SELECTOR=username=%u
      - EMQX_AUTH__MONGO__SUPER_QUERY__COLLECTION=mqtt_user
      - EMQX_AUTH__MONGO__SUPER_QUERY__SUPER_FIELD=is_superuser
      - EMQX_AUTH__MONGO__SUPER_QUERY__SELECTOR=username=%u
      - EMQX_AUTH__MONGO__ACL_QUERY__COLLECTION=mqtt_acl
      - EMQX_AUTH__MONGO__ACL_QUERY__SELECTOR=username=%u
    volumes:
      - emqx_data:/opt/emqx/data
      - emqx_etc:/opt/emqx/etc
      - emqx_log:/opt/emqx/log
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.emqx2-http.rule=Host(`emqx.<host>`)"
      - "traefik.http.routers.emqx2-http.entrypoints=http"
      - "traefik.http.routers.emqx2-http.middlewares=redirect-emqx"
      - "traefik.http.middlewares.redirect-emqx.redirectscheme.scheme=https"

      - traefik.http.routers.emqx-https.rule=Host(`emqx.<host>)
      - traefik.http.routers.emqx-https.entrypoints=https
      - traefik.http.routers.emqx-https.tls=true
      - traefik.http.routers.emqx-https.tls.certresolver=leresolver
      - traefik.http.routers.emqx-https.service=emqx
      - traefik.http.services.emqx.loadbalancer.server.port=18083

      - "traefik.tcp.routers.mqtt.rule=HostSNI(`mqtt.<host>`)"
      - "traefik.tcp.routers.mqtt.entrypoints=mqtt"
      - "traefik.tcp.routers.mqtt.service=mqtt"
      - "traefik.tcp.services.mqtt.loadbalancer.server.port=1883"

      - "traefik.tcp.routers.mqtt-ssl.rule=HostSNI(`mqtt.<host>`)"
      - "traefik.tcp.routers.mqtt-ssl.entrypoints=mqtt_ssl"
      - "traefik.tcp.routers.mqtt-ssl.service=mqtt_ssl"  
      - "traefik.tcp.routers.mqtt-ssl.tls=true"
      - "traefik.tcp.routers.mqtt-ssl.tls.certresolver=leresolver"
      - "traefik.tcp.services.mqtt_ssl.loadbalancer.server.port=1883"

      - "traefik.http.routers.mqtt_ws.rule=Host(`mqtt.<host>`)"
      - "traefik.http.routers.mqtt_ws.entrypoints=mqtt_ws"
      - "traefik.http.routers.mqtt_ws.service=mqtt_ws"  
      - "traefik.http.services.mqtt_ws.loadbalancer.server.port=8083"

      - "traefik.http.routers.mqtt-wss.rule=Host(`mqtt.<host>`)"
      - "traefik.http.routers.mqtt-wss.entrypoints=mqtt_wss"
      - "traefik.http.routers.mqtt-wss.service=mqtt_wss"  
      - "traefik.http.routers.mqtt-wss.tls=true"
      - "traefik.http.routers.mqtt-wss.tls.certresolver=leresolver"
      - "traefik.http.services.mqtt_wss.loadbalancer.server.port=8083"
    networks:
      - traefik_proxy

emqx2 needs a service, it has too many (>1) to choose from, you could use noop@internal for this.

Otherwise if you are only planning on using https then you can use entrypoint redirection instead.

What do you mean with service?

I add the service line like this.

      - "traefik.enable=true"
      - "traefik.http.routers.emqx-http.rule=Host(`emqx.<host>`)"
      - "traefik.http.routers.emqx-http.entrypoints=http"
      - "traefik.http.routers.emqx-http.middlewares=redirect-emqx"
      - "traefik.http.middlewares.redirect-emqx.redirectscheme.scheme=https"
      - "traefik.http.routers.emqx-http.service=emqx"