This repository contains an example of an ASP.NET Core reverse proxy using YARP (Yet Another Reverse Proxy).
For a detailed walkthrough on how to build this reverse proxy, read the Medium Blog.
Program.cs
: The main entry point of the application. Configures the reverse proxy and Kestrel server.CustomTransformer.cs
: Contains custom request and response transformers for the reverse proxy.appsettings.json
: Configuration file for the reverse proxy routes and clusters.sample-reverse-proxy.csproj
: Project file containing dependencies and build configurations.Properties/launchSettings.json
: Configuration for launching the application in different environments.
-
Clone the repository:
git clone [email protected]:manuel-io/sample-reverse-proxy.git cd sample-reverse-proxy
-
Update the destination URL in appsettings.json:
"ReverseProxy": { "Clusters": { "testCluster": { "Destinations": { "testDestination": { "Address": "<your-destination-url>" } } } } }
-
Run the application:
dotnet run
-
The reverse proxy will be available at
https://localhost:5027
.
The CustomTransformer class in CustomTransformer.cs allows you to customize the request and response transformations. The example logs the request and response bodies to the console.
The reverse proxy configuration is defined in appsettings.json. You can define routes and clusters to control how requests are proxied.
This project is licensed under the MIT License.