Files
Encelado/TradingBot/Program.cs
Alberto Balbo f69d5dd567 Configura Kestrel e accesso browser per Docker/Unraid
- Kestrel ora ascolta su 0.0.0.0:8080 per compatibilità Docker
- HTTPS redirect attivo solo in sviluppo, disabilitato in prod
- Aggiunta sezione "Kestrel" in appsettings.json e nuovo appsettings.Production.json con limiti di sicurezza
- Healthcheck Docker ora usa wget su /health (porta 8080)
- Aggiunta documentazione dettagliata in BROWSER_ACCESS_CONFIG.md
- Migliorata accessibilità browser, supporto reverse proxy e SignalR
2025-12-15 11:32:26 +01:00

53 lines
1.5 KiB
C#

using TradingBot.Components;
using TradingBot.Services;
var builder = WebApplication.CreateBuilder(args);
// Configure Kestrel per Docker - Listen su tutte le interfacce
builder.WebHost.ConfigureKestrel(serverOptions =>
{
// Listen su porta 8080 per Docker
serverOptions.ListenAnyIP(8080);
});
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
// Trading Bot Services - Using Simulated Market Data
builder.Services.AddSingleton<IMarketDataService, SimulatedMarketDataService>();
builder.Services.AddSingleton<ITradingStrategy, SimpleMovingAverageStrategy>();
builder.Services.AddSingleton<TradingBotService>();
builder.Services.AddSingleton<SettingsService>();
// Add health checks for Docker
builder.Services.AddHealthChecks();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
// Disabilita HTTPS redirect in Docker/Production
// Docker gestisce HTTPS tramite reverse proxy se necessario
if (app.Environment.IsDevelopment())
{
app.UseHttpsRedirection();
}
app.UseStaticFiles();
app.UseAntiforgery();
// Health check endpoint for Docker
app.MapHealthChecks("/health");
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();