soheilhy / cmux

Connection multiplexer for GoLang: serve different services on the same port!
Apache License 2.0
2.57k stars 196 forks source link

How do I serve SSL for both GRPC and HTTPS service? #41

Closed tamalsaha closed 7 years ago

tamalsaha commented 7 years ago

Hi, Thanks for this library. I am trying to serve GRPC and GRPC-gateway(only https) on the same port and terminate SSL for both at the go server. Do you mind showing example on how to do that? Here is a code example of what I am trying to do: https://github.com/appscode/appstream/blob/master/cmd/appstream/app/server.go#L48

Thanks.

soheilhy commented 7 years ago

An option, that I can think of, is to match grpc first and send all that's maching to your grpc listener: https://github.com/soheilhy/cmux/blob/master/example_test.go#L115 The rest should unconditionally be sent to the gateway.

tamalsaha commented 7 years ago

@soheilhy, thanks for answering. How do you use SSL with gRPC in that scenario?

tamalsaha commented 7 years ago

@soheilhy I think I understand how to handle TLS with gRPC services. Thanks.

vtolstov commented 6 years ago

can you share info @tamalsaha ?

tamalsaha commented 6 years ago

@vtolstov , here is an example grpc server using this library https://github.com/appscode/hello-grpc