poem icon indicating copy to clipboard operation
poem copied to clipboard

Add reverse proxy support

Open banool opened this issue 2 years ago • 5 comments

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!

banool avatar Jan 10 '23 20:01 banool

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.

banool avatar Jan 10 '23 20:01 banool

Maybe you can try poem-grpc, which also supports reflection.

sunli829 avatar Jan 11 '23 23:01 sunli829

Or I add reverse proxy support to poem, which is easier.

sunli829 avatar Jan 11 '23 23:01 sunli829

Okay yeah I'll try poem-grpc, though having a reverse proxy in Poem would still be helpful as part of this experimentation 😄

banool avatar Jan 12 '23 10:01 banool

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.

AlexMikhalev avatar Jan 26 '23 00:01 AlexMikhalev