docker – traefik – expose secondary internal port via new subdomain

I’ve written a .NET API application that listens on two ports:

  • 5000 for regular HTTP requests (HTTP1)
  • 5001 for gRPC (HTTP2)

I’m deploying my images via docker-compose using labels:

  - "traefik.enable=true"
  - "traefik.http.routers.myApi.rule=Host(``)"
  - "traefik.http.routers.myApientrypoints=websecure"
  - "traefik.http.routers.myApitls.certresolver=myresolver"

Now, my question is – if my container EXPOSEs 5000 as well as 5001, how do I setup a new subdomain so that I can allow regular web traffic as well as gRPC?

So that:

HTTP1 -> container:5000
HTTP2 -> container:5001

If there is a better way of achieving the same, please let me know. I cannot have gRPC listen on the same port as web traffic due to the strict HTTP2 requirement, and I’d rather not use gRPC-web.

Read more here: Source link