- contatti.astro: widget hCaptcha, token incluso nel payload, messaggio di errore se challenge non completata - docs/INFRA.md: documentata configurazione hCaptcha (site key, secret key in appSettings, flusso di verifica) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
111 lines
3.6 KiB
Markdown
111 lines
3.6 KiB
Markdown
# Infrastruttura — SmartRootsSite
|
|
|
|
## Overview
|
|
|
|
Sito istituzionale statico generato con **Astro 4**, deployato su **IIS / Windows Server 2016** presso Hetzner.
|
|
|
|
- URL: https://www.smart-roots.net/
|
|
- Cartella sul server: `C:\inetpub\wwwroot\smartroots-site\`
|
|
- Backend API: https://api.smart-roots.net/ (progetto SmartRootsServices)
|
|
|
|
---
|
|
|
|
## Struttura IIS — Site `smart-roots`
|
|
|
|
Il Site IIS `smart-roots` ha come Physical Path `C:\inetpub\wwwroot\smartroots-site\`.
|
|
Sotto di esso convivono due tipi di nodi:
|
|
|
|
### Virtual Applications (webapp con proprio App Pool)
|
|
Sopravvivono automaticamente al cambio di Physical Path del Site.
|
|
|
|
`/investirehub`, `/mantis`, `/motoregrafico`, `/olympiadocs`, `/reports`, `/services`,
|
|
`/smartreports`, `/smartwiki`, `/testblazor`, `/tradingview`, `/wiki`, `/zertimporter`
|
|
|
|
### Virtual Directories (contenuto statico, nessun App Pool)
|
|
Vanno ricreate manualmente se si cambia la Physical Path del Site.
|
|
Puntano tutte a sottocartelle di `C:\inetpub\wwwroot\smart-roots.net\`.
|
|
|
|
| Alias | Physical path |
|
|
|---|---|
|
|
| `.well-known` | `...\smart-roots.net\.well-known\` — ⚠️ necessario per rinnovo SSL |
|
|
| `allegati` | `...\smart-roots.net\allegati\` |
|
|
| `Images` | `...\smart-roots.net\Images\` |
|
|
| `Pdf` | `...\smart-roots.net\Pdf\` |
|
|
| `PricerApi` | `...\smart-roots.net\PricerApi\` |
|
|
| `PricerApp` | `...\smart-roots.net\PricerApp\` |
|
|
| `PricerApp2` | `...\smart-roots.net\PricerApp2\` |
|
|
| `video` | `...\smart-roots.net\video\` |
|
|
|
|
---
|
|
|
|
## Deploy (da ripetere ad ogni aggiornamento)
|
|
|
|
```powershell
|
|
npm run build
|
|
Copy-Item -Path "dist\*" -Destination "C:\inetpub\wwwroot\smartroots-site\" -Recurse -Force
|
|
```
|
|
|
|
Nessuna modifica IIS necessaria per i deploy ordinari.
|
|
|
|
---
|
|
|
|
## web.config — nota critica
|
|
|
|
Il file `public/web.config` (copiato da Astro in `dist/` durante la build) contiene:
|
|
|
|
1. **Redirect HTTP→HTTPS**
|
|
2. **Astro static routing** — fallback catch-all che riscrive URL senza file fisico a `/{path}/index.html`
|
|
3. **httpErrors 404** — serve `/index.html` per qualsiasi 404
|
|
|
|
L'intera sezione `<system.webServer>` è avvolta in:
|
|
|
|
```xml
|
|
<location path="." inheritInChildApplications="false">
|
|
```
|
|
|
|
**Questo wrapper è fondamentale.** Senza di esso, le regole di rewrite e il gestore 404
|
|
vengono ereditati dalle Virtual Applications figlie, che ricevono traffico riscritto
|
|
o risposte sostituite con la homepage Astro invece dei loro contenuti.
|
|
|
|
Sintomo senza il wrapper: endpoint dinamici delle webapp (es. `/smartreports/api/report?p=...`)
|
|
restituiscono la homepage Astro invece del contenuto atteso.
|
|
|
|
---
|
|
|
|
## Pagine
|
|
|
|
| URL | File |
|
|
|---|---|
|
|
| `/` | `src/pages/index.astro` |
|
|
| `/contatti` | `src/pages/contatti.astro` |
|
|
| `/privacy` | `src/pages/privacy.astro` |
|
|
| `/termini` | `src/pages/termini.astro` |
|
|
|
|
## API usate dal frontend
|
|
|
|
| Endpoint | Metodo | Scopo |
|
|
|---|---|---|
|
|
| `https://api.smart-roots.net/api/contatti` | POST | Invio form contatti |
|
|
|
|
Il controller è in `SmartRootsServices/SRServices/Controllers/SmartRootsSite/ContattiController.cs`.
|
|
|
|
Validazioni lato server: campi obbligatori, messaggio minimo 10 caratteri,
|
|
rate limiting (3 invii/ora per IP), honeypot anti-bot, verifica hCaptcha.
|
|
|
|
---
|
|
|
|
## hCaptcha
|
|
|
|
Il form contatti è protetto da **hCaptcha** (piano gratuito).
|
|
|
|
- **Site key** (pubblica, nel frontend): `813a0980-869a-42f4-9a7c-abaae7dccd96`
|
|
- **Secret key** (privata, solo server): configurata in `<appSettings>` nel `web.config`
|
|
di SmartRootsServices sul server — **non è in source control**
|
|
|
|
```xml
|
|
<add key="HcaptchaSecret" value="..." />
|
|
```
|
|
|
|
Il controller verifica il token chiamando `https://hcaptcha.com/siteverify` prima
|
|
di processare il form. Se la verifica fallisce restituisce HTTP 400.
|