microsoft / reverse-proxy

A toolkit for developing high-performance HTTP reverse proxy applications.
https://microsoft.github.io/reverse-proxy
MIT License
8.53k stars 838 forks source link

dynamically configure Redirects in Routes? #2576

Closed burtonrodman closed 3 weeks ago

burtonrodman commented 2 months ago

Some details

Hello, my question is this: I realize that YARP is meant for proxying, not redirecting, but YARP does provide an elegant dynamic configuration system that is not default to .Net Core's Redirect setup... ie dynamically configuring Redirects in .Net Core is hard 😢

I looked at the YARP route configuration and didn't see any notion of Redirects. My current application has a table of Redirects that get configured on startup, but they are not dynamic -- ie if they change in the database we have to restart the site.

As a part of a rewrite of our app we're using YARP to proxy some pages to the new site and some to the old.

However, given that my YARP project now effectively provides a nice "pinch point" for all things route(ish), it seems like a good place to also handle general redirects in a more dynamic way.

Is there anything built-in that I'm missing, or can you point me to any examples that I could use to come to a solution for dynamically configurable redirects.

For some background, an example redirect is a feature of the old site that we're deprecating now should be redirected to the homepage.

How many backends are in your application?

How do you host your application?

Tratcher commented 2 months ago

You're right that this isn't natively supported, but you could add it with custom transforms keyed from config. https://microsoft.github.io/reverse-proxy/articles/transforms.html#extensibility https://github.com/microsoft/reverse-proxy/pull/1923

karelz commented 2 months ago

@burtonrodman did you look at the above? Is it sufficient for you?

burtonrodman commented 2 months ago

sorry, haven't had a chance to look back at this. will do asap.

karelz commented 1 month ago

@burtonrodman do you have rough ETA when it might be good time to check out the answer? Or should we close it as resolved and let you reopen if you find more problems / questions later?

MihaZupan commented 3 weeks ago

Closing as this is not actionable by us at the momemnt. Feel free to reopen if/when you have more info/questions.