-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
64 lines (50 loc) · 1.79 KB
/
Program.cs
File metadata and controls
64 lines (50 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using NginxPanel.Services;
using Radzen;
using System.Net;
using System.Security.Cryptography.X509Certificates;
var builder = WebApplication.CreateBuilder(args);
// Initialize application configuration
// NOTE: This creates files including self-signed.pfx!
NginxPanel.AppConfig.Init();
// Verify port is set and PFX exists
if (NginxPanel.AppConfig.Port <= 0)
{
// Fail on port not set
throw new Exception($"Must specify '{nameof(NginxPanel.AppConfig.Port)}' in the configuration file!");
}
else if (!File.Exists(NginxPanel.AppConfig.PFXPath))
{
// Fail on non-existent PFX
throw new Exception($"Specified PFX file at '{NginxPanel.AppConfig.PFXPath}' does not exist! Clear this value in the config to create a new self-signed one.");
}
builder.WebHost.ConfigureKestrel((context, serverOptions) =>
{
serverOptions.Listen(IPAddress.Any, NginxPanel.AppConfig.Port, listenOptions =>
{
listenOptions.UseHttps(X509CertificateLoader.LoadPkcs12FromFile(NginxPanel.AppConfig.PFXPath, NginxPanel.AppConfig.PFXPassword));
});
});
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddRadzenComponents();
// Add custom services.
builder.Services.AddSingleton<Cli>();
builder.Services.AddSingleton<Nginx>();
builder.Services.AddSingleton<Acme>();
builder.Services.AddScoped<Duo>();
builder.Services.AddScoped<AuthState>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
await app.RunAsync();