commit 7aef2d1603c19d8f6ef40402c599bb16db5ecf43 Author: wangyu Date: Tue Aug 29 14:49:21 2023 +0800 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b7f4e76 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.vs +bin +obj +*.user diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..de43cfd --- /dev/null +++ b/Program.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; + +var builder = WebApplication.CreateBuilder(args); + +var reverseProxyConfig = builder.Configuration.GetSection("ReverseProxy"); + +builder.Services.AddReverseProxy().LoadFromConfig(reverseProxyConfig); + +var app = builder.Build(); + +app.UseRouting(); + +app.MapReverseProxy(); + +app.Run(); \ No newline at end of file diff --git a/Properties/PublishProfiles/FolderProfile.pubxml b/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..90b170f --- /dev/null +++ b/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,18 @@ + + + + + Release + Any CPU + bin\Release\net7.0\publish\linux-x64\ + FileSystem + <_TargetId>Folder + net7.0 + linux-x64 + true + true + false + + \ No newline at end of file diff --git a/WebProxy.csproj b/WebProxy.csproj new file mode 100644 index 0000000..1f6db86 --- /dev/null +++ b/WebProxy.csproj @@ -0,0 +1,24 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + Always + + + + + + + + diff --git a/WebProxy.sln b/WebProxy.sln new file mode 100644 index 0000000..c61b94d --- /dev/null +++ b/WebProxy.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33530.505 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebProxy", "WebProxy.csproj", "{F86D9D9B-DC67-42B4-AAEA-14562C6501BA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F86D9D9B-DC67-42B4-AAEA-14562C6501BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F86D9D9B-DC67-42B4-AAEA-14562C6501BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F86D9D9B-DC67-42B4-AAEA-14562C6501BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F86D9D9B-DC67-42B4-AAEA-14562C6501BA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7EF45312-00A6-406A-B1C6-813B8CA8B93A} + EndGlobalSection +EndGlobal diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..cdf4986 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,22 @@ +{ + "ReverseProxy": { + "Routes": { + "route1": { + "ClusterId": "yarp", + "Match": { + "Path": "{**catch-all}" + } + } + }, + "Clusters": { + "yarp": { + "LoadBalancingPolicy": "RoundRobin", + "Destinations": { + "openai": { + "Address": "https://api.openai.com/" + } + } + } + } + } +} \ No newline at end of file