Re: [grpc-io] Routing a grpc server to a url without port with Apache

283 views
Skip to first unread message

Eric Anderson

unread,
Feb 23, 2023, 11:27:34 AM2/23/23
to Adam Beer, grpc.io
(Sorry for the moderation delay here. The spam detection kicked in; false positives are pretty rare so it isn't checked super regularly. I approved just one of the duplicate emails.)

The problem here is probably the "/rpc". gRPC doesn't use the /rpc prefix. It uses /package.Service/Method, so you'd route based on which services you want sent to the backend. gRPC implementations generally don't support path prefixes, so you couldn't tell the client to prepend /rpc to the path for the request.

On Thu, Feb 23, 2023 at 8:21 AM Adam Beer <adamb...@gmail.com> wrote:
I am trying to route my gRPC server to a url with a specific path on an Apache 2 server but am getting DNS resolving errors on my client when I try to connect. I would like to host my gRPC server behind example.com/rpc and my Apache config looks like this:

Protocols h2 http/1.1
ProxyPass /rpc h2://127.0.0.1:5051
ProxyPassReverse /rpc https://127.0.0.1:5051

Im using the grpc package on Node. My server is being bound to the 5051 port with the following:

server.bind("0.0.0.0:5051", grpc.ServerCredentials.createInsecure());
server.start();

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/0efe7a2f-5285-4b40-a6ef-e2f2a6a95ffdn%40googlegroups.com.
Message has been deleted

Eric Anderson

unread,
Feb 24, 2023, 8:08:04 PM2/24/23
to Adam Beer, grpc.io
Right, that's what I was discussing. You can't generally configure gRPC clients to use a path prefix. I'd suggest routing by service name, but some people route by Content-Type (which is technically wrong from an HTTP perspective, but doesn't generally hurt much and is very easy).

On Fri, Feb 24, 2023 at 5:05 PM Adam Beer <adam...@boldstratus.com> wrote:
All good! I understand the package.Service/Method structure but what Im trying to do is set the url portition before the service path. I dont want someone to have to use example.com:5051/package.Service/Method, I want example.com/rpc/package.Service/Method. Im hosting a REST and RPC api on the same server. REST has traffic routed to /api through the grpc-gateway service but I have no idea how to do this for grpc. Idealy id like to have both API's flow through the same url minus but I dont know if this is possible.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages