Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.9.0.115408">
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.12.0.118525">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
3 changes: 0 additions & 3 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Henrik Jensen</Authors>
<Description>Pairs Microsoft YARP with a web API for runtime configuration and automatic self-signed certificates.</Description>
<PackageTags>testing;reverse-proxy;certificates</PackageTags>
<PackageProjectUrl>https://github.com/henrikhimself/DotNet-ReverseProxy</PackageProjectUrl>
<RepositoryUrl>https://github.com/henrikhimself/DotNet-ReverseProxy.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>1.0.0-beta2</Version>
</PropertyGroup>

</Project>
92 changes: 92 additions & 0 deletions ReverseProxy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReverseProxy", "src\Reverse
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReverseProxy.UnitTest", "test\ReverseProxy.UnitTest\ReverseProxy.UnitTest.csproj", "{44CD6750-C3BF-45B7-B292-8BFBCC5216C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples.Aspire", "Examples.Aspire", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.Aspire.AppHost", "examples\Aspire.AppHost\Examples.Aspire.AppHost.csproj", "{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReverseProxy.Aspire", "src\ReverseProxy.Aspire\ReverseProxy.Aspire.csproj", "{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.Aspire.ReverseProxy", "examples\Aspire.ReverseProxy\Examples.Aspire.ReverseProxy.csproj", "{24BE0E35-2042-4683-25DD-2F8B4990ACE1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.Aspire.Website", "examples\Aspire.Website\Examples.Aspire.Website.csproj", "{0187E74D-09DC-B681-B851-F6949AED4278}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.Aspire.ServiceDefaults", "examples\Aspire.ServiceDefaults\Examples.Aspire.ServiceDefaults.csproj", "{166DED15-CF0E-B2E5-532F-53B48FA98A65}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReverseProxy.Aspire.UnitTest", "test\ReverseProxy.Aspire.UnitTest\ReverseProxy.Aspire.UnitTest.csproj", "{62D393F1-7F63-7A78-36E2-A309877EB476}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -41,10 +55,88 @@ Global
{44CD6750-C3BF-45B7-B292-8BFBCC5216C4}.Release|x64.Build.0 = Release|Any CPU
{44CD6750-C3BF-45B7-B292-8BFBCC5216C4}.Release|x86.ActiveCfg = Release|Any CPU
{44CD6750-C3BF-45B7-B292-8BFBCC5216C4}.Release|x86.Build.0 = Release|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Debug|Any CPU.Build.0 = Debug|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Debug|x64.ActiveCfg = Debug|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Debug|x64.Build.0 = Debug|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Debug|x86.ActiveCfg = Debug|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Debug|x86.Build.0 = Debug|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Release|Any CPU.ActiveCfg = Release|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Release|Any CPU.Build.0 = Release|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Release|x64.ActiveCfg = Release|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Release|x64.Build.0 = Release|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Release|x86.ActiveCfg = Release|Any CPU
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929}.Release|x86.Build.0 = Release|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Debug|x64.ActiveCfg = Debug|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Debug|x64.Build.0 = Debug|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Debug|x86.ActiveCfg = Debug|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Debug|x86.Build.0 = Debug|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Release|Any CPU.Build.0 = Release|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Release|x64.ActiveCfg = Release|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Release|x64.Build.0 = Release|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Release|x86.ActiveCfg = Release|Any CPU
{E3A0F3EA-CA80-AABB-ACF6-27E8C34A1D63}.Release|x86.Build.0 = Release|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Debug|x64.ActiveCfg = Debug|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Debug|x64.Build.0 = Debug|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Debug|x86.ActiveCfg = Debug|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Debug|x86.Build.0 = Debug|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Release|Any CPU.Build.0 = Release|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Release|x64.ActiveCfg = Release|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Release|x64.Build.0 = Release|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Release|x86.ActiveCfg = Release|Any CPU
{24BE0E35-2042-4683-25DD-2F8B4990ACE1}.Release|x86.Build.0 = Release|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Debug|x64.ActiveCfg = Debug|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Debug|x64.Build.0 = Debug|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Debug|x86.ActiveCfg = Debug|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Debug|x86.Build.0 = Debug|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Release|Any CPU.Build.0 = Release|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Release|x64.ActiveCfg = Release|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Release|x64.Build.0 = Release|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Release|x86.ActiveCfg = Release|Any CPU
{0187E74D-09DC-B681-B851-F6949AED4278}.Release|x86.Build.0 = Release|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Debug|x64.ActiveCfg = Debug|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Debug|x64.Build.0 = Debug|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Debug|x86.ActiveCfg = Debug|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Debug|x86.Build.0 = Debug|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Release|Any CPU.Build.0 = Release|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Release|x64.ActiveCfg = Release|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Release|x64.Build.0 = Release|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Release|x86.ActiveCfg = Release|Any CPU
{166DED15-CF0E-B2E5-532F-53B48FA98A65}.Release|x86.Build.0 = Release|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Debug|x64.ActiveCfg = Debug|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Debug|x64.Build.0 = Debug|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Debug|x86.ActiveCfg = Debug|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Debug|x86.Build.0 = Debug|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Release|Any CPU.Build.0 = Release|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Release|x64.ActiveCfg = Release|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Release|x64.Build.0 = Release|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Release|x86.ActiveCfg = Release|Any CPU
{62D393F1-7F63-7A78-36E2-A309877EB476}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{707F131B-6DB8-B2E3-2789-F0F2BCEEE929} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{24BE0E35-2042-4683-25DD-2F8B4990ACE1} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{0187E74D-09DC-B681-B851-F6949AED4278} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{166DED15-CF0E-B2E5-532F-53B48FA98A65} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5CEEA7D1-CF67-453E-BE4B-8ADC68410EA6}
EndGlobalSection
Expand Down
5 changes: 5 additions & 0 deletions examples/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = false

[*.cs]
# CA1515: Consider making public types internal
dotnet_diagnostic.CA1515.severity = none
22 changes: 22 additions & 0 deletions examples/Aspire.AppHost/Examples.Aspire.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.3.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<IsAspireHost>true</IsAspireHost>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\ReverseProxy.Aspire\ReverseProxy.Aspire.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\Aspire.ReverseProxy\Examples.Aspire.ReverseProxy.csproj" />
<ProjectReference Include="..\Aspire.Website\Examples.Aspire.Website.csproj" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions examples/Aspire.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Hj.ReverseProxy.Aspire;
using Projects;

var builder = DistributedApplication.CreateBuilder(args);

// Add example website.
var website = builder.AddProject<Examples_Aspire_Website>("Website", options =>
{
// Do not use endpoint configuration found in the Website project. We let aspire set up everything.
options.ExcludeLaunchProfile = true;
options.ExcludeKestrelEndpoints = true;
})
// Add a HTTP endpoint. The reverse proxy will set up a secure HTTPS endpoint for you to connect to this resource.
.WithHttpEndpoint();

// Add reverse proxy website.
var reverseProxy = builder
.AddProject<Examples_Aspire_ReverseProxy>("Reverse-Proxy")
// Map a host name to the endpoint of the example website.
.WithReverseProxyReference("Website", website.GetEndpoint("http"), "example-website.local");

// Wait for the website to be healthy.
reverseProxy.WaitFor(website);

await builder.Build().RunAsync();
17 changes: 17 additions & 0 deletions examples/Aspire.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17294",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21134",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22265"
}
}
}
}
8 changes: 8 additions & 0 deletions examples/Aspire.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
13 changes: 13 additions & 0 deletions examples/Aspire.ReverseProxy/Examples.Aspire.ReverseProxy.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\ReverseProxy.Aspire\ReverseProxy.Aspire.csproj" />
<ProjectReference Include="..\..\src\ReverseProxy\ReverseProxy.csproj" />
</ItemGroup>

</Project>
31 changes: 31 additions & 0 deletions examples/Aspire.ReverseProxy/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Hj.ReverseProxy;
using Hj.ReverseProxy.Aspire;

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(options =>
{
// Adds a certificate resolver to Kestrel that dynamically generates a self-signed certificate when
// needed to service a HTTP request. Trust is added to these using a Root Certificate Authority that
// is created and saved to a configured location (see "SelfSignedCertificate" section in appsettings).
// You need to make your system trust this Root CA by importing it into your certificate store. Also
// make sure you don't delete the generated Root CA once created and imported.
options.UseSelfSignedCertificate();
});

// Register injected Aspire resource service discovery variables as YARP Routes and Clusters on startup.
// If you're missing some at runtime then you may want to consider making the reverse proxy resource
// wait for the resources that it should proxy.
builder.Services.AddTransient<IStartupFilter, ServiceDiscoveryStartupFilter>();

// Configure the reverse proxy.
builder.Services.ConfigureReverseProxy(builder.Configuration);

var app = builder.Build();

// Use the configured reverse proxy.
app.UseReverseProxy();

// No further routes are registered. This means that you will get a 404 error status on all requests
// that do not match a proxied Aspire resource.
await app.RunAsync();
9 changes: 9 additions & 0 deletions examples/Aspire.ReverseProxy/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"applicationUrl": "https://localhost:443"
}
}
}
12 changes: 12 additions & 0 deletions examples/Aspire.ReverseProxy/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"SelfSignedCertificate": {
"CaFilePath": "c:/"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<IsAspireSharedProject>true</IsAspireSharedProject>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.7.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.3.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
</ItemGroup>

</Project>
Loading
Loading