dotnet version : 6.0
dotnet new web -n MyProxy -f net6.0
dotnet add package Yarp.ReverseProxy
添加中间件
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddReverseProxy().LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
app.MapReverseProxy();
app.Run();
配置代理
上面的代码可以看出来配置写在appsettings.xxx.json中的