first commit
Some checks failed
Build and Deploy / deploy (push) Has been cancelled
Build and Deploy / build (push) Has been cancelled

This commit is contained in:
2026-01-23 09:59:19 +01:00
commit 2eddd152d7
17 changed files with 1895 additions and 0 deletions

68
traefik-example/README.md Normal file
View File

@@ -0,0 +1,68 @@
# Esempio Configurazione Traefik
Questa directory contiene un esempio di configurazione Traefik per il server di produzione.
## Setup Iniziale
1. Crea la directory sul server:
```bash
mkdir -p /opt/traefik/letsencrypt
cd /opt/traefik
```
2. Copia il file docker-compose.yml in questa directory
3. Modifica l'email per Let's Encrypt:
```bash
nano docker-compose.yml
# Modifica: tua-email@example.com
```
4. Crea la rete Docker:
```bash
docker network create traefik-network
```
5. Avvia Traefik:
```bash
docker-compose up -d
```
6. Verifica che sia attivo:
```bash
docker ps
docker logs traefik
```
## Note di Sicurezza
- **Dashboard**: La configurazione include il dashboard Traefik con autenticazione basic
- Per generare una nuova password per il dashboard:
```bash
# Installa htpasswd se necessario: apt-get install apache2-utils
htpasswd -nb admin tuapassword
```
- In produzione, considera di rimuovere completamente il dashboard o limitarlo a IP specifici
## Configurazione Domini
Dopo aver avviato Traefik, i tuoi container con le labels corrette saranno automaticamente esposti con:
- Certificati SSL Let's Encrypt
- Redirect automatico HTTP → HTTPS
- Routing basato sul dominio
## Troubleshooting
### Certificati non vengono generati
- Verifica che la porta 80 sia accessibile pubblicamente
- Controlla i logs: `docker logs traefik`
- Verifica che il dominio punti all'IP del server
- Assicurati che il file `acme.json` abbia i permessi corretti:
```bash
chmod 600 letsencrypt/acme.json
```
### Container non raggiungibili
- Verifica che il container sia sulla rete `traefik-network`
- Controlla i logs di Traefik per errori
- Verifica le labels del container con: `docker inspect nome-container`

View File

@@ -0,0 +1,66 @@
# Esempio di configurazione Traefik
# Da usare come riferimento per configurare Traefik sul server di produzione
version: '3.8'
services:
traefik:
image: traefik:v2.10
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
command:
# Dashboard
- "--api.dashboard=true"
# Provider Docker
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik-network"
# Entrypoints
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
# Redirect HTTP to HTTPS
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
# Let's Encrypt
- "--certificatesresolvers.letsencrypt.acme.email=tua-email@example.com"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
# Logs
- "--log.level=INFO"
- "--accesslog=true"
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./letsencrypt:/letsencrypt
networks:
- traefik-network
labels:
# Dashboard (opzionale, rimuovi in produzione se non necessario)
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`traefik.tuodominio.com`)"
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.routers.dashboard.tls=true"
- "traefik.http.routers.dashboard.tls.certresolver=letsencrypt"
- "traefik.http.routers.dashboard.service=api@internal"
# Autenticazione basic per dashboard
# Username: admin, Password: changeme (genera il tuo con: htpasswd -nb admin password)
- "traefik.http.routers.dashboard.middlewares=dashboard-auth"
- "traefik.http.middlewares.dashboard-auth.basicauth.users=admin:$$apr1$$8EVjn/nj$$GiLUZqcbueTFeD23SuB6x0"
networks:
traefik-network:
external: true