???????????????????????????????????????????
? Utenti (Browser) ?
? https://securebootdashboard.local ?
???????????????????????????????????????????
?
?
???????????????????????????????????????????
? IIS - SecureBootDashboard.Web ?
? Frontend Razor Pages ?
? Port 443 (HTTPS) ?
? C:\inetpub\SecureBootDashboard.Web ?
???????????????????????????????????????????
? HTTP/HTTPS
?
???????????????????????????????????????????
? IIS - SecureBootDashboard.Api ?
? Backend REST API ?
? Port 5001 (HTTPS) ?
? C:\inetpub\SecureBootDashboard.Api ?
???????????????????????????????????????????
?
?
???????????????????????????????????????????
? SQL Server (SRVSQL) ?
? Database: SecureBootDashboard ?
???????????????????????????????????????????
- Windows Server 2016+ o Windows 10/11
- IIS con ASP.NET Core Hosting Bundle 8.0
- .NET 8 Runtime (ASP.NET Core Runtime)
- SQL Server (locale o remoto)
- Certificati SSL per HTTPS
# Installa IIS e funzionalità necessarie
Install-WindowsFeature -Name Web-Server, Web-Asp-Net45, Web-Windows-Auth- Scarica da: https://dotnet.microsoft.com/download/dotnet/8.0
- Cerca "Hosting Bundle" e installa
- Riavvia IIS:
iisreset
dotnet --list-runtimes
# Deve mostrare Microsoft.AspNetCore.App 8.0.xcd C:\Users\nefario\source\repos\robgrame\Nimbus.BootCertWatcher
dotnet publish SecureBootDashboard.Api\SecureBootDashboard.Api.csproj `
-c Release `
-o C:\Deploy\SecureBootDashboard.Apidotnet publish SecureBootDashboard.Web\SecureBootDashboard.Web.csproj `
-c Release `
-o C:\Deploy\SecureBootDashboard.WebCREATE DATABASE SecureBootDashboard;
GO# Dal PC di sviluppo, con connection string temporanea al server
cd SecureBootDashboard.Api
# Modifica appsettings.json temporaneamente con la connection string del server
dotnet ef database updateUSE [master]
GO
CREATE LOGIN [IIS APPPOOL\SecureBootDashboard.Api] FROM WINDOWS
GO
USE [SecureBootDashboard]
GO
CREATE USER [IIS APPPOOL\SecureBootDashboard.Api] FOR LOGIN [IIS APPPOOL\SecureBootDashboard.Api]
GO
ALTER ROLE [db_datareader] ADD MEMBER [IIS APPPOOL\SecureBootDashboard.Api]
ALTER ROLE [db_datawriter] ADD MEMBER [IIS APPPOOL\SecureBootDashboard.Api]
GOImport-Module WebAdministration
New-WebAppPool -Name "SecureBootDashboard.Api"
Set-ItemProperty IIS:\AppPools\SecureBootDashboard.Api -Name managedRuntimeVersion -Value ""
Set-ItemProperty IIS:\AppPools\SecureBootDashboard.Api -Name processModel.identityType -Value 2# Crea directory
New-Item -Path "C:\inetpub\SecureBootDashboard.Api" -ItemType Directory -Force
# Copia file pubblicati
Copy-Item -Path "C:\Deploy\SecureBootDashboard.Api\*" `
-Destination "C:\inetpub\SecureBootDashboard.Api" `
-Recurse -ForceModifica C:\inetpub\SecureBootDashboard.Api\appsettings.json:
{
"ConnectionStrings": {
"SqlServer": "Server=SRVSQL;Database=SecureBootDashboard;Trusted_Connection=True;TrustServerCertificate=True"
},
"Storage": {
"Provider": "EfCore"
},
"QueueProcessor": {
"Enabled": false
}
}New-Website -Name "SecureBootDashboard.Api" `
-PhysicalPath "C:\inetpub\SecureBootDashboard.Api" `
-ApplicationPool "SecureBootDashboard.Api" `
-Port 5001 `
-Ssl
# Binding con certificato (sostituisci con il tuo thumbprint)
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object {$_.Subject -like "*secureboot*"}
New-WebBinding -Name "SecureBootDashboard.Api" -Protocol https -Port 5001 -SslFlags 0
$binding = Get-WebBinding -Name "SecureBootDashboard.Api" -Protocol https
$binding.AddSslCertificate($cert.Thumbprint, "My")icacls "C:\inetpub\SecureBootDashboard.Api" `
/grant "IIS AppPool\SecureBootDashboard.Api:(OI)(CI)F" /TNew-WebAppPool -Name "SecureBootDashboard.Web"
Set-ItemProperty IIS:\AppPools\SecureBootDashboard.Web -Name managedRuntimeVersion -Value ""New-Item -Path "C:\inetpub\SecureBootDashboard.Web" -ItemType Directory -Force
Copy-Item -Path "C:\Deploy\SecureBootDashboard.Web\*" `
-Destination "C:\inetpub\SecureBootDashboard.Web" `
-Recurse -ForceModifica C:\inetpub\SecureBootDashboard.Web\appsettings.json:
{
"ApiSettings": {
"BaseUrl": "https://localhost:5001"
}
}O crea appsettings.Production.json:
{
"ApiSettings": {
"BaseUrl": "https://api.securebootdashboard.local"
}
}New-Website -Name "SecureBootDashboard.Web" `
-PhysicalPath "C:\inetpub\SecureBootDashboard.Web" `
-ApplicationPool "SecureBootDashboard.Web" `
-Port 443 `
-Ssl
# Binding con hostname
New-WebBinding -Name "SecureBootDashboard.Web" `
-Protocol https `
-Port 443 `
-HostHeader "securebootdashboard.local"
# Associa certificato
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object {$_.Subject -like "*secureboot*"}
$binding = Get-WebBinding -Name "SecureBootDashboard.Web" -Protocol https
$binding.AddSslCertificate($cert.Thumbprint, "My")icacls "C:\inetpub\SecureBootDashboard.Web" `
/grant "IIS AppPool\SecureBootDashboard.Web:(OI)(CI)F" /TAggiungi a C:\Windows\System32\drivers\etc\hosts:
127.0.0.1 securebootdashboard.local
127.0.0.1 api.securebootdashboard.local
Aggiungi l'IP del server:
192.168.1.100 securebootdashboard.local
192.168.1.100 api.securebootdashboard.local
Invoke-WebRequest -Uri "https://localhost:5001/health" -UseBasicParsing
# Deve rispondere con 200 OKApri browser e vai su: https://securebootdashboard.local
Problema: ASP.NET Core Hosting Bundle non installato
Soluzione:
# Scarica e installa Hosting Bundle
# Poi riavvia IIS
iisresetProblema: Errore nell'applicazione o manca il runtime
Soluzione:
- Verifica i log in
C:\inetpub\SecureBootDashboard.Api\logs - Controlla
appsettings.json - Verifica connection string
Problema: Application Pool identity non ha permessi su SQL
Soluzione:
-- Esegui su SQL Server
CREATE LOGIN [IIS APPPOOL\SecureBootDashboard.Api] FROM WINDOWS
USE [SecureBootDashboard]
CREATE USER [IIS APPPOOL\SecureBootDashboard.Api] FOR LOGIN [IIS APPPOOL\SecureBootDashboard.Api]
ALTER ROLE [db_datareader] ADD MEMBER [IIS APPPOOL\SecureBootDashboard.Api]
ALTER ROLE [db_datawriter] ADD MEMBER [IIS APPPOOL\SecureBootDashboard.Api]Problema: BaseUrl non corretto o firewall
Soluzione:
- Verifica
ApiSettings:BaseUrlinappsettings.json - Testa connettività:
Test-NetConnection localhost -Port 5001 - Controlla firewall Windows
# Stop siti
Stop-Website "SecureBootDashboard.Web"
Stop-Website "SecureBootDashboard.Api"
# Pubblica nuove versioni
dotnet publish [...] -o C:\Deploy\...
# Copia file
Copy-Item -Path "C:\Deploy\..." -Destination "C:\inetpub\..." -Recurse -Force
# Start siti
Start-Website "SecureBootDashboard.Api"
Start-Website "SecureBootDashboard.Web"BACKUP DATABASE [SecureBootDashboard]
TO DISK = 'C:\Backup\SecureBootDashboard.bak'
WITH FORMAT, INIT, COMPRESSION;# API logs
Get-Content "C:\inetpub\SecureBootDashboard.Api\logs\*.log" -Tail 50
# IIS logs
Get-Content "C:\inetpub\logs\LogFiles\W3SVC*\*.log" -Tail 50Entrambi i siti sono configurati solo per HTTPS.
Usa identità con privilegi minimi necessari.
# Apri solo le porte necessarie
New-NetFirewallRule -DisplayName "SecureBootDashboard API" `
-Direction Inbound -LocalPort 5001 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "SecureBootDashboard Web" `
-Direction Inbound -LocalPort 443 -Protocol TCP -Action AllowPer problemi o domande, consultare la documentazione principale nel README.md del repository.