question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Path prefixes: how?

See original GitHub issue

Hi all,

I have a very basic question and cannot find an answer yet.

This is what I have from docs:

const echoService = new EchoServiceClient('http://localhost:8080', null, null);

That’s all fine until it comes to deployment to the real world where I have just one domain (let’s say this is a limitation) and want to split the traffic by path prefixes as one normally does in REST.

In other words this is the desired URL structure:

and the configuration of the client would be

const echoService = new EchoServiceClient('https://example.com/grpc-proxy', null, null);

or even more preferrable

const echoService = new EchoServiceClient('/grpc-proxy', null, null);

There is an option to configure some sort of path prefix strip and make one more proxy step on the envoy itself, so it looks something like

browser => envoy proxy strip path prefix => envoy grpc web proxy => grpc server

However, it looks dirty.

And I am still unsure whether the grpc-web library itself is going to support the non-root path prefixes such as described above in the long run .

Is this possible? Is there an example how to configure envoy in this case?

Thanks in advance.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
snarlysodboxercommented, Jun 9, 2022

I was up against this same problem. For me, in the end it was a relatively easy fix with the envoy config. Specifically the prefix_rewrite as seen here: image

0reactions
smnbbrvcommented, Feb 19, 2020

Actually finally I got the proper way to handle this. It has a limitation that you need to own the proto files and services to be able to modify them (if they do not supply what’s described below).

Every RPC call has the following structure:

/package.subpackage.ServiceName/RpcName

So, it is just enough to give the packages a unique enough name that could be used as a prefix path.

E.g. there is the following service

syntax = "proto3";

import "google/protobuf/empty.proto";

service EchoService {
  rpc Echo(google.protobuf.Empty) returns (google.protobuf.Empty);
}

The Echo call will have the /EchoService/Echo URL path.

Now let’s add the proper package.

syntax = "proto3";

// the package name is just an example
package mybackends.echobackend.echo

import "google/protobuf/empty.proto"; 

service EchoService {
  rpc Echo(google.protobuf.Empty) returns (google.protobuf.Empty);
}

and the URL path will become /mybackends.echobackend.echo.EchoService/Echo.

The generated URL is very descriptive and can easily be used to split the calls. These are example masks to match it:

  • /mybackends.* - wraps all backends into one sub-url. Very useful for frontend if you have multiple backends, otherwise you need to keep in mind multiple paths which you are not allowed to use in the frontend routers / page urls. Also could be used by load balancer to delegate path matching to e.g. envoy
  • /mybackends.echobackend.* - points to the specific backend. This one is the load balancer marker to point to the specific backend
  • by going deeper you can further configure atomic services and even calls

@stanley-cheung could this be added to the documentation? I know, probably this repo should not document the sysadmin guides; however the infrastructure is very important here and it’s not that easy to find out how to properly configure it…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Path prefixes \??\ and \\?\ - Stack Overflow
In NT, "\??\" is a path prefix that stands for the object directory that's reserved for a user's devices, or more specifically, ...
Read more >
Adding a Path Prefix - Gatsby
Adding the path prefix is a two step process as you'll see below. ... Serve your application with the --prefix-paths flag, like so:....
Read more >
Configuring the IMAP path prefix - Fastmail Help
An IMAP path prefix tells your mail client where to look for your mail. Most clients will automatically set up the IMAP prefix...
Read more >
Prefix in std::path - Rust
Windows uses a variety of path prefix styles, including references to drive volumes (like C: ), network shared folders (like \\server\share ), and...
Read more >
Configuring Host Mapping, Path Prefix, and Path Mapping
The path prefixes and path mappings apply only to hosts for which you have set WS HTTP Mapping. Procedure. 1. Access the Reverse...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found