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:
labels: - "traefik.enable=true" - "traefik.http.routers.myApi.rule=Host(`api.example.com`)" - "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?
HTTP1 https://api.example.com -> container:5000 HTTP2 https://api-grpc.example.com -> 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.
Source: Docker Questions