Compare commits
2 Commits
bc75ce30c2
...
63bcdf5c7f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63bcdf5c7f | ||
|
|
13a7cd6d96 |
@@ -44,10 +44,8 @@ function Test-SSHConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-TodaysBackups {
|
function Get-TodaysBackups {
|
||||||
Write-Log "Searching for today's backup files..."
|
Write-Log "Searching for backup files..."
|
||||||
|
|
||||||
$today = Get-Date
|
|
||||||
$cutoffDate = $today.Date # Only today (after midnight)
|
|
||||||
$backupFiles = @()
|
$backupFiles = @()
|
||||||
|
|
||||||
$searchPaths = @(
|
$searchPaths = @(
|
||||||
@@ -57,10 +55,9 @@ function Get-TodaysBackups {
|
|||||||
|
|
||||||
foreach ($path in $searchPaths) {
|
foreach ($path in $searchPaths) {
|
||||||
if (Test-Path $path) {
|
if (Test-Path $path) {
|
||||||
# Get files created TODAY only (exclude old backups)
|
# Get ALL backup files (duplicates will be skipped during transfer)
|
||||||
$files = Get-ChildItem -Path $path -Recurse -File -ErrorAction SilentlyContinue |
|
$files = Get-ChildItem -Path $path -Recurse -File -ErrorAction SilentlyContinue |
|
||||||
Where-Object {
|
Where-Object {
|
||||||
$_.LastWriteTime -gt $cutoffDate -and
|
|
||||||
$_.Name -notlike "*__TAG_*" # Exclude old uncompressed backups
|
$_.Name -notlike "*__TAG_*" # Exclude old uncompressed backups
|
||||||
} |
|
} |
|
||||||
Sort-Object LastWriteTime -Descending
|
Sort-Object LastWriteTime -Descending
|
||||||
@@ -70,7 +67,7 @@ function Get-TodaysBackups {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($backupFiles.Count -eq 0) {
|
if ($backupFiles.Count -eq 0) {
|
||||||
Write-Log "No backup files found for today!" "WARNING"
|
Write-Log "No backup files found!" "WARNING"
|
||||||
return @()
|
return @()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
201
proxmox/certificat-letsencrypt-iis.md
Normal file
201
proxmox/certificat-letsencrypt-iis.md
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
# Certificat Let's Encrypt pentru IIS - Ghid Rapid
|
||||||
|
|
||||||
|
## Instalare Win-ACME
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# Download și instalare
|
||||||
|
Invoke-WebRequest -Uri "https://github.com/win-acme/win-acme/releases/download/v2.2.9.1701/win-acme.v2.2.9.1701.x64.pluggable.zip" -OutFile "$env:TEMP\win-acme.zip"
|
||||||
|
Expand-Archive -Path "$env:TEMP\win-acme.zip" -DestinationPath "C:\Tools\win-acme" -Force
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prerequisite IIS
|
||||||
|
|
||||||
|
### Verificare Site ID-uri
|
||||||
|
```powershell
|
||||||
|
Import-Module WebAdministration
|
||||||
|
Get-Website | Select-Object ID, Name, State, @{N='Bindings';E={$_.Bindings.Collection.bindingInformation}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adaugă Binding-uri pentru Domeniu
|
||||||
|
```powershell
|
||||||
|
# Exemplu pentru roa.romfast.ro pe Default Web Site
|
||||||
|
New-WebBinding -Name "Default Web Site" -Protocol http -Port 80 -HostHeader "roa.romfast.ro"
|
||||||
|
New-WebBinding -Name "Default Web Site" -Protocol https -Port 443 -HostHeader "roa.romfast.ro"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Generare Certificate
|
||||||
|
|
||||||
|
### Metoda 1: Comenzi PowerShell (Automat)
|
||||||
|
```powershell
|
||||||
|
cd C:\Tools\win-acme
|
||||||
|
|
||||||
|
# Pentru fiecare site (înlocuiește Site ID și email)
|
||||||
|
.\wacs.exe --source iis --siteid 1 --accepttos --emailaddress your@email.com
|
||||||
|
.\wacs.exe --source iis --siteid 2 --accepttos --emailaddress your@email.com
|
||||||
|
.\wacs.exe --source iis --siteid 3 --accepttos --emailaddress your@email.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### Metoda 2: Mod Interactiv
|
||||||
|
```powershell
|
||||||
|
cd C:\Tools\win-acme
|
||||||
|
.\wacs.exe
|
||||||
|
|
||||||
|
# În meniu:
|
||||||
|
# N - Create certificate (simple for IIS)
|
||||||
|
# Selectează site-ul
|
||||||
|
# Confirmă binding-urile
|
||||||
|
# yes - Accept ToS
|
||||||
|
# Enter email
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configurare Binding-uri IIS cu SNI
|
||||||
|
|
||||||
|
### Important: SNI OBLIGATORIU pentru Multiple Certificate pe Același IP
|
||||||
|
|
||||||
|
**GUI - IIS Manager:**
|
||||||
|
1. Deschide IIS Manager (`inetmgr`)
|
||||||
|
2. Pentru fiecare site:
|
||||||
|
- Site → **Bindings** → Selectează **https** → **Edit**
|
||||||
|
- ☑️ **Bifează "Require Server Name Indication"**
|
||||||
|
- Selectează **certificatul corect** pentru site
|
||||||
|
- **OK**
|
||||||
|
3. Restart IIS: `iisreset`
|
||||||
|
|
||||||
|
**PowerShell:**
|
||||||
|
```powershell
|
||||||
|
Import-Module WebAdministration
|
||||||
|
|
||||||
|
# Exemplu pentru un site
|
||||||
|
$siteName = "Dokploy"
|
||||||
|
$hostHeader = "dokploy.romfast.ro"
|
||||||
|
|
||||||
|
# Găsește certificatul
|
||||||
|
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object {
|
||||||
|
$_.Subject -like "*$hostHeader*" -and $_.NotAfter -gt (Get-Date).AddDays(60)
|
||||||
|
} | Select-Object -First 1
|
||||||
|
|
||||||
|
# Șterge binding vechi și creează cu SNI (SslFlags = 1)
|
||||||
|
Remove-WebBinding -Name $siteName -Protocol https -HostHeader $hostHeader -ErrorAction SilentlyContinue
|
||||||
|
New-WebBinding -Name $siteName -Protocol https -Port 443 -HostHeader $hostHeader -SslFlags 1
|
||||||
|
|
||||||
|
# Asociază certificatul
|
||||||
|
$binding = Get-WebBinding -Name $siteName -Protocol https -HostHeader $hostHeader
|
||||||
|
$binding.AddSslCertificate($cert.Thumbprint, "My")
|
||||||
|
|
||||||
|
# Restart IIS
|
||||||
|
iisreset
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verificare
|
||||||
|
|
||||||
|
### Listare Certificate Gestionate
|
||||||
|
```powershell
|
||||||
|
cd C:\Tools\win-acme
|
||||||
|
.\wacs.exe --list
|
||||||
|
```
|
||||||
|
|
||||||
|
### Verificare Certificate în Browser
|
||||||
|
```bash
|
||||||
|
# Din WSL sau Linux
|
||||||
|
echo | openssl s_client -connect domain.ro:443 -servername domain.ro 2>/dev/null | openssl x509 -noout -dates -subject
|
||||||
|
```
|
||||||
|
|
||||||
|
### Verificare Task Scheduler
|
||||||
|
```powershell
|
||||||
|
Get-ScheduledTask | Where-Object {$_.TaskName -like "*acme*"}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Verificare Certificate IIS
|
||||||
|
```powershell
|
||||||
|
Get-ChildItem Cert:\LocalMachine\My | Where-Object {
|
||||||
|
$_.Issuer -like "*Let's Encrypt*" -and $_.NotAfter -gt (Get-Date)
|
||||||
|
} | Select-Object Subject, NotAfter, Thumbprint
|
||||||
|
```
|
||||||
|
|
||||||
|
## Reînnoire
|
||||||
|
|
||||||
|
### Automată
|
||||||
|
- Task Scheduler verifică zilnic
|
||||||
|
- Reînnoiește automat cu 30 zile înainte de expirare
|
||||||
|
|
||||||
|
### Manuală
|
||||||
|
```powershell
|
||||||
|
cd C:\Tools\win-acme
|
||||||
|
.\wacs.exe --renew --force
|
||||||
|
iisreset
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Certificat Vechi Încă Servit
|
||||||
|
```powershell
|
||||||
|
# Verifică SNI
|
||||||
|
Get-WebBinding | Where-Object {$_.Protocol -eq "https"} | Select-Object @{N='Site';E={$_.ItemXPath -replace '.*name=''([^'']+)''.*','$1'}}, bindingInformation, @{N='SNI';E={($_.sslFlags -band 1) -eq 1}}
|
||||||
|
|
||||||
|
# Forțează reinstalare
|
||||||
|
cd C:\Tools\win-acme
|
||||||
|
.\wacs.exe --renew --force
|
||||||
|
iisreset
|
||||||
|
```
|
||||||
|
|
||||||
|
### Validare HTTP-01 Eșuează
|
||||||
|
- Verifică că portul 80 este accesibil din internet
|
||||||
|
- Verifică că DNS pointează corect
|
||||||
|
- Verifică că URL Rewrite nu blochează `/.well-known/acme-challenge/*`
|
||||||
|
|
||||||
|
### Certificate Nu Se Asociază Automat
|
||||||
|
Folosește scriptul: `configure-iis-sni.ps1`
|
||||||
|
|
||||||
|
## Structură Site-uri IIS
|
||||||
|
|
||||||
|
| Site ID | Nume | Hostname | Binding HTTPS | SNI |
|
||||||
|
|---------|--------------------|-----------------------|------------------------|----------|
|
||||||
|
| 1 | Default Web Site | roa.romfast.ro | *:443:roa.romfast.ro | ☑️ Activ |
|
||||||
|
| 2 | Dokploy | dokploy.romfast.ro | *:443:dokploy.romfast.ro | ☑️ Activ |
|
||||||
|
| 3 | Gitea | gitea.romfast.ro | *:443:gitea.romfast.ro | ☑️ Activ |
|
||||||
|
|
||||||
|
## Scripturi Utile
|
||||||
|
|
||||||
|
### Script Complet Configurare SNI
|
||||||
|
Locație: `/mnt/e/proiecte/ROMFASTSQL/proxmox/scripts/configure-iis-sni.ps1`
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
cd D:\kit\ssl
|
||||||
|
.\configure-iis-sni.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Script Verificare Certificate
|
||||||
|
Locație: `/mnt/e/proiecte/ROMFASTSQL/proxmox/scripts/verify-letsencrypt.ps1`
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
cd D:\kit\ssl
|
||||||
|
.\verify-letsencrypt.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Comenzi Rapide
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# Instalare
|
||||||
|
Expand-Archive win-acme.zip -DestinationPath C:\Tools\win-acme
|
||||||
|
|
||||||
|
# Generare certificate
|
||||||
|
cd C:\Tools\win-acme
|
||||||
|
.\wacs.exe --source iis --siteid X --accepttos --emailaddress email@domain.com
|
||||||
|
|
||||||
|
# Verificare
|
||||||
|
.\wacs.exe --list
|
||||||
|
|
||||||
|
# Reînnoire
|
||||||
|
.\wacs.exe --renew --force
|
||||||
|
|
||||||
|
# Restart IIS
|
||||||
|
iisreset
|
||||||
|
```
|
||||||
|
|
||||||
|
## Note Importante
|
||||||
|
|
||||||
|
- **SNI este OBLIGATORIU** pentru multiple certificate pe același IP:port
|
||||||
|
- Certificatele expiră la **90 zile**
|
||||||
|
- Task Scheduler reînnoiește automat cu **30 zile** înainte
|
||||||
|
- Fiecare domeniu trebuie să fie **accesibil pe port 80** din internet pentru validare HTTP-01
|
||||||
|
- DNS trebuie să pointeze corect către IP-ul public
|
||||||
Reference in New Issue
Block a user