-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Primo commit AutenticazioneSvc LoadBalancer
- Loading branch information
1 parent
c305716
commit a50ed65
Showing
6 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Yarp.ReverseProxy" Version="2.2.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
20 changes: 20 additions & 0 deletions
20
src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | ||
WORKDIR /app | ||
EXPOSE 5001 | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
WORKDIR /src | ||
COPY ["src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj", "src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/"] | ||
RUN dotnet restore "src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/AutenticazioneSvc.LoadBalancer.csproj" | ||
COPY . . | ||
|
||
WORKDIR "/src/src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer" | ||
RUN dotnet build "AutenticazioneSvc.LoadBalancer.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "AutenticazioneSvc.LoadBalancer.csproj" -c Release -o /app/publish /p:UseAppHost=false | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "AutenticazioneSvc.LoadBalancer.dll"] |
33 changes: 33 additions & 0 deletions
33
src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.AspNetCore.Server.Kestrel.Core; | ||
|
||
namespace AutenticazioneSvc.LoadBalancer; | ||
|
||
public class Program | ||
{ | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
/// <param name="args">The command-line arguments.</param> | ||
public static void Main(string[] args) | ||
{ | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add reverse proxy services and load configuration from appsettings | ||
builder.Services.AddReverseProxy() | ||
.LoadFromConfig(builder.Configuration.GetSection("LoadBalancer")); | ||
|
||
// Configure Kestrel server options | ||
builder.Services.Configure<KestrelServerOptions>(builder.Configuration.GetSection("Kestrel")); | ||
|
||
// Configure route options to use lowercase URLs | ||
builder.Services.Configure<RouteOptions>(options => options.LowercaseUrls = true); | ||
|
||
var app = builder.Build(); | ||
|
||
// Map reverse proxy routes | ||
app.MapReverseProxy(); | ||
|
||
// Run the application | ||
app.Run(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:24524", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5083", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/AutenticazioneSvc/AutenticazioneSvc.LoadBalancer/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"LoadBalancer": { | ||
"Routes": { | ||
"route1": { | ||
"ClusterId": "cluster1", | ||
"Match": { | ||
"Path": "{**catch-all}" | ||
} | ||
} | ||
}, | ||
"Clusters": { | ||
"cluster1": { | ||
//"LoadBalancingPolicy": "RoundRobin", | ||
"Destinations": { | ||
"destination1": { | ||
"Address": "http://NOME-DOCKER-API:5001" | ||
} | ||
//"destination1": { | ||
// "Address": "http://[Host]:[Port]/" | ||
//}, | ||
//"destination2": { | ||
// "Address": "http://[Host]:[Port]/" | ||
//} | ||
} | ||
} | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |