From a720688bfd9508ffc63592b3d74042d8a7f2fd68 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 24 Mar 2024 20:27:38 +0100 Subject: [PATCH] Add LoadBalancer bundle to Elsa.Server This commit introduces a new bundle for load balancing into the Elsa.Server solution. It includes initial configuration files, launch settings, and reverse proxy setup. The load balancer is configured with a RoundRobin policy and the project references the Yarp.ReverseProxy package. --- .../Elsa.Server.LoadBalancer.csproj | 13 +++++++ .../Elsa.Server.LoadBalancer/FodyWeavers.xml | 1 + .../Elsa.Server.LoadBalancer/Program.cs | 5 +++ .../Properties/launchSettings.json | 38 +++++++++++++++++++ .../appsettings.Development.json | 8 ++++ .../Elsa.Server.LoadBalancer/appsettings.json | 29 ++++++++++++++ 6 files changed, 94 insertions(+) create mode 100644 src/bundles/Elsa.Server.LoadBalancer/Elsa.Server.LoadBalancer.csproj create mode 100644 src/bundles/Elsa.Server.LoadBalancer/FodyWeavers.xml create mode 100644 src/bundles/Elsa.Server.LoadBalancer/Program.cs create mode 100644 src/bundles/Elsa.Server.LoadBalancer/Properties/launchSettings.json create mode 100644 src/bundles/Elsa.Server.LoadBalancer/appsettings.Development.json create mode 100644 src/bundles/Elsa.Server.LoadBalancer/appsettings.json diff --git a/src/bundles/Elsa.Server.LoadBalancer/Elsa.Server.LoadBalancer.csproj b/src/bundles/Elsa.Server.LoadBalancer/Elsa.Server.LoadBalancer.csproj new file mode 100644 index 000000000..138ee315f --- /dev/null +++ b/src/bundles/Elsa.Server.LoadBalancer/Elsa.Server.LoadBalancer.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/src/bundles/Elsa.Server.LoadBalancer/FodyWeavers.xml b/src/bundles/Elsa.Server.LoadBalancer/FodyWeavers.xml new file mode 100644 index 000000000..06ee72161 --- /dev/null +++ b/src/bundles/Elsa.Server.LoadBalancer/FodyWeavers.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/bundles/Elsa.Server.LoadBalancer/Program.cs b/src/bundles/Elsa.Server.LoadBalancer/Program.cs new file mode 100644 index 000000000..1a98c9fb1 --- /dev/null +++ b/src/bundles/Elsa.Server.LoadBalancer/Program.cs @@ -0,0 +1,5 @@ +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddReverseProxy().LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")); +var app = builder.Build(); +app.MapReverseProxy(); +app.Run(); \ No newline at end of file diff --git a/src/bundles/Elsa.Server.LoadBalancer/Properties/launchSettings.json b/src/bundles/Elsa.Server.LoadBalancer/Properties/launchSettings.json new file mode 100644 index 000000000..241626351 --- /dev/null +++ b/src/bundles/Elsa.Server.LoadBalancer/Properties/launchSettings.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:28212", + "sslPort": 44310 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5272", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7036;http://localhost:5272", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/bundles/Elsa.Server.LoadBalancer/appsettings.Development.json b/src/bundles/Elsa.Server.LoadBalancer/appsettings.Development.json new file mode 100644 index 000000000..0c208ae91 --- /dev/null +++ b/src/bundles/Elsa.Server.LoadBalancer/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/bundles/Elsa.Server.LoadBalancer/appsettings.json b/src/bundles/Elsa.Server.LoadBalancer/appsettings.json new file mode 100644 index 000000000..6ce85ebce --- /dev/null +++ b/src/bundles/Elsa.Server.LoadBalancer/appsettings.json @@ -0,0 +1,29 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "ReverseProxy": { + "Routes": { + "route1": { + "ClusterId": "cluster1", + "Match": { + "Path": "{**catch-all}" + } + } + }, + "Clusters": { + "cluster1": { + "LoadBalancingPolicy": "RoundRobin", + "Destinations": { + "cluster1/destination1": { + "Address": "https://localhost:5001/" + } + } + } + } + } +}