poem
poem copied to clipboard
Add reverse proxy support
Hello again after a while!
For the next iteration of our API we're considering using grpc. Currently our API runs exclusively with Poem, at /v1
. I'd like to use Poem to route requests to /v2/grpc
to the grpc backend. I understand this is probably easy with poem-grpc, but for now I'm working with tonic because it has some features I need, e.g. tonic-reflection
.
Furthermore, down the line I'd like to host a JSON-reflected version of the API, so /v2/resource
, /v2/account
, etc. for example. That's not possible for free right now unfortunately (I'd need something like this: https://github.com/poem-web/poem/issues/359 or https://github.com/tokio-rs/prost/issues/301#issuecomment-1377681201), but it's something I'd need to keep in mind for the reverse proxy use case.
Does Poem have support for this kind of raw reverse proxy? In the past when I first migrated us to Poem I used this (https://crates.io/crates/warp-reverse-proxy), but I'd prefer not to use warp again hahah.
Thanks!
I figure one option that could work out of the box is using axum + the tower extension support in Poem, though that feels pretty hacky.
Maybe you can try poem-grpc
, which also supports reflection
.
Or I add reverse proxy support to poem, which is easier.
Okay yeah I'll try poem-grpc
, though having a reverse proxy in Poem would still be helpful as part of this experimentation 😄
Although my use case is different I vote for reverse proxy support: Having poem with Oauth2 + reverse proxy to another upstream poem instance will allow me to remove multiple components from infrastructure like caddy, nginx, oauth2-proxy.