With YARP(Yet-Another-Reverse-Proxy) you can transform your ASP.NET Core application into a reverse proxy.
It offers features like routing, discovery, load balancing, retries,... However in the application I'm building that is a lot more then what I need. I only need the ability to take a specific request and forward it to a specific destination. In that case you can use Direct Forwarding through the IHttpForwarder.
- Dynamic destination selection, you specify the destination for each request
- Http client customization, you provide the HttpMessageInvoker
- Request and response customization (except bodies)
- Streaming protocols like gRPC and WebSockets
- Error handling
It does not include:
- Load balancing
Direct forwarding in .NET 6 and beyond
You can find an example of Direct Forwarding in the documentation. However this documentation is written for .NET 5 still using the
Let me share an example on how to achieve the same thing in .NET 6:
You can find the complete example here: https://github.com/wullemsb/YarpDirectForwarding