Traefik with gRPC and Let's Encrypt?

Viewed 1649

I followed the Traefik guide to setting up Let's Encrypt and Docker, and now my-domain.com properly accepts HTTPS with a static website behind it. Next I'd like to get a gRPC server running behind Traefik at my-grpc-server.my-domain.com. Looking at the Traefik documentation for using gRPC with Traefik, I see that the instructions are to use self-signed certificates. How do I take advantage of the fact that I already have valid certificates from Let's Encrypt?

Taking a stab at a solution... in my grpc-server Docker container, I could maybe mount the acme.json file that Traefik writes, read the keys from that file, and use them to initialize the gRPC server. That'd require some grunt work, which is fine, but even then it seems like I'd maybe still need a different traefik.toml configuration to account for the fact that the traffic between Traefik and my grpc-server Docker container need SSL.


UPDATE: I've been giving this a try with no success so far. I manually exported the acme keys for testing this so as to get the Let's Encrypt stuff out of the picture for simplicity's sake.

Here's the gRPC client error: grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.CANCELLED, Received http2 header with status: 500)>

And the Traefik error: level=warning msg="Error forwarding to https://172.18.0.2:443, err: stream error: stream ID 1; INTERNAL_ERROR"

Curiously, when I connect with the gRPC client, there is no message on the gRPC server. However, when I hit my-grpc-server.my-server.com in a web browser I get the same error in Traefik and an additional error on the gRPC server: E1112 21:06:37.480636928 8 http_server_filter.c:236] GET request without QUERY I'm wondering now why the traffic gets forwarded in the web browser case but not the gRPC client case.

1 Answers

To communicate in https between your traefik and your container, you need to add the label traefik.protocol=https on your container (https://docs.traefik.io/configuration/backends/docker/#on-containers)

Moreover, with the docker backend when traefik will contact your backend server, it will use the IP of the container (and it doesn't match your domain certificate). So you may can active InsecureSkipVerify in your traefik configuration (https://docs.traefik.io/configuration/commons/#main-section).

Related