推荐使用框架:Yarp.ReverseProxy,微软开源的框架
一基本使用
var builder = WebApplication.CreateSlimBuilder(args); builder.Services.AddReverseProxy() .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")); var app = builder.Build(); app.MapReverseProxy(); app.Run();
appsettings.json
"ReverseProxy":{ "Routes":{ "ROUTE_NAME":{ "ClusterId": "yarp", "Match": { "Path": "{**catch-all}" } } }, "Clusters":{ "yarp": { "LoadBalancingPolicy": "RoundRobin", "Destinations": { "microsoft": { "Address": "https://docs.microsoft.com/zh-cn/" }, "github":{ "Address": "https://github.com/" } } } } },
启动项目,发现可以自动调整到github官网上。
------------------分割线-------------------------------------
其他功能待续。
标签:core,github,app,反向,https,Address,net,ReverseProxy,builder From: https://www.cnblogs.com/Insist-Y/p/17560210.html