- Add .env file for production deployment with reverse proxy - Add docker-compose.prod.yml for production profile - Add docker-compose.override.yml for local development - Update docker-compose.yml with all configurable variables - Update frontend to use VITE_* environment variables - Update backend to support CORS_ORIGINS and WEBHOOK_BASE_URL - Add vite.config.ts allowedHosts for reverse proxy - Add documentation for docker-compose and reverse proxy setup All URLs are now configurable via environment variables: - VITE_API_URL: Backend API endpoint - VITE_WEBHOOK_BASE_URL: Webhook base URL - VITE_INSTALL_SCRIPT_URL: Install script URL - VITE_APP_URL: Frontend URL - CORS_ORIGINS: Allowed CORS origins - WEBHOOK_BASE_URL: Backend webhook base URL
3.9 KiB
3.9 KiB
Configurazione con Reverse Proxy
Questa guida spiega come configurare LogWhispererAI con un reverse proxy SSL.
Scenario
Hai configurato:
- Frontend:
https://logwhispererai.lab.home.lucasacchi.net→http://192.168.254.79:5173 - Backend:
https://srv-logwhispererai.lab.home.lucasacchi.net→http://192.168.254.79:3001
Configurazione
1. Crea il file di configurazione
Crea un file .env nella root del progetto:
cp .env.example .env
Modifica il file .env con i tuoi valori:
# Frontend Configuration
VITE_API_URL=https://srv-logwhispererai.lab.home.lucasacchi.net
VITE_WEBHOOK_BASE_URL=https://logwhispererai.lab.home.lucasacchi.net/webhook
VITE_INSTALL_SCRIPT_URL=https://logwhispererai.lab.home.lucasacchi.net/install.sh
VITE_APP_NAME=LogWhispererAI
VITE_APP_URL=https://logwhispererai.lab.home.lucasacchi.net
# Backend Configuration
CORS_ORIGINS=https://logwhispererai.lab.home.lucasacchi.net
WEBHOOK_BASE_URL=https://logwhispererai.lab.home.lucasacchi.net/webhook
DELAY_MS=1500
NODE_ENV=production
2. Avvia i servizi
# Ferma eventuali container esistenti
docker compose down
# Avvia con le nuove variabili
docker compose up -d
3. Verifica la configurazione
Testa i vari endpoint:
# Health check backend
curl https://srv-logwhispererai.lab.home.lucasacchi.net/health
# Genera un webhook
curl -X POST https://srv-logwhispererai.lab.home.lucasacchi.net/api/webhook
# Analizza un log
curl -X POST https://srv-logwhispererai.lab.home.lucasacchi.net/api/analyze \
-H "Content-Type: application/json" \
-d '{"log": "FATAL: out of memory"}'
4. Verifica il frontend
Apri https://logwhispererai.lab.home.lucasacchi.net nel browser e verifica che:
- La demo interattiva funzioni (chiama il backend corretto)
- Lo step 2 dell'onboarding generi webhook con l'URL corretto
Variabili d'Ambiente
Frontend (VITE_*)
| Variabile | Descrizione | Esempio |
|---|---|---|
VITE_API_URL |
URL del backend API | https://srv-logwhispererai.lab.home.lucasacchi.net |
VITE_WEBHOOK_BASE_URL |
Base URL per i webhook | https://logwhispererai.lab.home.lucasacchi.net/webhook |
VITE_INSTALL_SCRIPT_URL |
URL dello script di installazione | https://logwhispererai.lab.home.lucasacchi.net/install.sh |
VITE_APP_NAME |
Nome dell'applicazione | LogWhispererAI |
VITE_APP_URL |
URL pubblico dell'app | https://logwhispererai.lab.home.lucasacchi.net |
Backend
| Variabile | Descrizione | Esempio |
|---|---|---|
CORS_ORIGINS |
Origini CORS consentite (comma-separated) | https://logwhispererai.lab.home.lucasacchi.net |
WEBHOOK_BASE_URL |
Base URL per i webhook generati | https://logwhispererai.lab.home.lucasacchi.net/webhook |
DELAY_MS |
Delay simulato API (ms) | 1500 |
NODE_ENV |
Ambiente Node | production |
File Configurati
frontend/.env- Configurazione frontend per produzionefrontend/.env.development- Configurazione per sviluppo localefrontend/vite.config.ts- Allow hosts per Vitetools/fake-backend/server.js- Supporto CORS dinamico e webhook URL configurabilidocker-compose.yml- Passaggio variabili ai container
Troubleshooting
Errore "Blocked request" di Vite
Se vedi questo errore:
Blocked request. This host ("logwhispererai.lab.home.lucasacchi.net") is not allowed.
Aggiungi il dominio a frontend/vite.config.ts:
server: {
allowedHosts: [
'logwhispererai.lab.home.lucasacchi.net',
],
}
Errore CORS
Se il browser blocca le richieste API:
- Verifica che
CORS_ORIGINSincluda il dominio del frontend - Ricostruisci il backend:
docker compose up fake-backend --build -d
Webhook URL errati
Se i webhook generati hanno URL sbagliati:
- Verifica
WEBHOOK_BASE_URLnel backend - Verifica
VITE_WEBHOOK_BASE_URLnel frontend - Ricostruisci entrambi i servizi