Your reverse proxy, your way (original) (raw)
YARP
Fast, flexible, and easy to extend—YARP lets you build a reverse proxy tailored to your needs in just a few lines of code.
Build a Reverse Proxy in Minutes
Configure and extend with just a few lines of .NET code.
Customize to Fit Your Needs
Fine-grained control over routing, load balancing, and health checks.
Optimized for Performance & Scale
Supports gRPC, WebSockets, HTTP/2, and HTTP/3.
Trusted at Scale
YARP is used by teams at Microsoft to handle billions of requests daily, powering services at massive scale.
Quick Start
Check out our full Getting Started tutorial, or dive right in with some code or a pre-built container.
Get started with YARP using a code-first approach. This snippet sets up a basic reverse proxy.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
app.MapReverseProxy();
app.Run();
Put the following configuration in appsettings.json
. YARP supports loading configuration from any IConfiguration provider. See Configuration Files for more details.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ReverseProxy": {
"Routes": {
"route1": {
"ClusterId": "cluster1",
"Match": {
"Path": "{**catch-all}"
}
}
},
"Clusters": {
"cluster1": {
"Destinations": {
"destination1": {
"Address": "https://example.com/"
}
}
}
}
}
}
⚠️ Preview: The YARP container experience is currently in Preview. We are actively working on improvements, and we welcome your feedback!
The YARP container is a quick way to get started with YARP. It's a pre-built proxy using YARP packaged as a docker container. Supply a configuration file and you are ready to route traffic!
# Run a YARP container with a custom config file, mapping port 5000.
# Make sure to replace the path to your config file.
# See docs for more info on configuration.
docker run --rm -v $(pwd)/my-config.config:/etc/yarp.config \
-p 5000:5000 mcr.microsoft.com/dotnet/nightly/yarp:latest
The configuration for YARP is defined in a configuration file that should be mapped to /etc/yarp.config
. See Configuration Files for more details.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ReverseProxy": {
"Routes": {
"route1": {
"ClusterId": "cluster1",
"Match": {
"Path": "{**catch-all}"
}
}
},
"Clusters": {
"cluster1": {
"Destinations": {
"destination1": {
"Address": "https://example.com/"
}
}
}
}
}
}