Https+h2c: Could not define the service name for the router: too many services


I have found this error many times in Google, but nothing seems to fit my situation: I want to map two different routers to one service like so:

      - traefik-public
      - spiff-backend
        - micromodel=true
        - traefik.enable=true
        - traefik.constraint-label=traefik-public
        - traefik.http.routers.spiff-backend-grpcui-interest-h2c.rule=Host(``)
        - traefik.http.routers.spiff-backend-grpcui-interest-h2c.entrypoints=grpc
        - traefik.http.routers.spiff-backend-grpcui-interest-h2c.tls=true
        - traefik.http.routers.spiff-backend-grpcui-interest-h2c.tls.certresolver=le
        - traefik.http.routers.spiff-backend-grpcui-interest-https.rule=Host(``)
        - traefik.http.routers.spiff-backend-grpcui-interest-https.entrypoints=https
        - traefik.http.routers.spiff-backend-grpcui-interest-https.tls=true
        - traefik.http.routers.spiff-backend-grpcui-interest-https.tls.certresolver=le

This leads to this:
"Could not define the service name for the router: too many services"

I found hints that I should add

        - traefik.http.routers.spiff-backend-grpcui-interest-h2c.service=interest_v1
        - traefik.http.routers.spiff-backend-grpcui-interest-https.service=interest_v1

But that also doesn't work; the error then is "no such service: interest_v1@docker". How can I make both these services available?

The routers don't know which service to use, there is more than one so implicit selection wont work. Use a service label on the router:

    image: twoport
      traefik.enable: "true"
      traefik.http.routers.1.rule: Host(``)
      traefik.http.routers.1.entrypoints: websecure
      traefik.http.routers.1.service: one 80
      traefik.http.routers.2.rule: Host(``)
      traefik.http.routers.2.entrypoints: websecure
      traefik.http.routers.2.service: two 81

Thanks - but isn't that exactly what I did in the second part of my post? It doesn't work, it claims to not find the service as shown.

How would this look if both ports run on the same service?

You did not define a http service interest_v1 which is why you get that error. Notice that my example creates two services one and two there is no reference to the docker service.

Both 80 and 81 are running on this service twoport.

You defined two services:


So those are the name you want to use for the router's service.

Ahhh, that makes sense! Thank you, I got it now :slight_smile: