Skip to content

manuelcoca/sample-reverse-proxy

Repository files navigation

ASP.NET Reverse Proxy Example

This repository contains an example of an ASP.NET Core reverse proxy using YARP (Yet Another Reverse Proxy).

Medium Blog

For a detailed walkthrough on how to build this reverse proxy, read the Medium Blog.

Project Structure

  • 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.

Getting Started

Prerequisites

Running the Application

  1. Clone the repository:

    git clone [email protected]:manuel-io/sample-reverse-proxy.git
    cd sample-reverse-proxy
  2. Update the destination URL in appsettings.json:

    "ReverseProxy": {
      "Clusters": {
        "testCluster": {
          "Destinations": {
            "testDestination": {
              "Address": "<your-destination-url>"
            }
          }
        }
      }
    }
  3. Run the application:

    dotnet run
  4. The reverse proxy will be available at https://localhost:5027.

Custom Transformers

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.

Configuration

The reverse proxy configuration is defined in appsettings.json. You can define routes and clusters to control how requests are proxied.

Dependencies

License

This project is licensed under the MIT License.

About

A sample ASP.NET reverse proxy built with YARP.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages