Compare commits

...

2 Commits

5 changed files with 46 additions and 28 deletions

View File

@@ -1,8 +0,0 @@
# Email de Let's Encrypt para notificaciones
ACME_EMAIL=admin@tudominio.com
# Dominio para el dashboard (opcional)
TRAEFIK_DASHBOARD_DOMAIN=traefik.tudominio.com
# Zona horaria
TZ=Europe/Madrid

View File

@@ -78,23 +78,27 @@ docker compose up -d
Este stack expone el dashboard por dominio usando TLS y el servicio interno `api@internal`. Este stack expone el dashboard por dominio usando TLS y el servicio interno `api@internal`.
Para proteger con autenticación básica (opcional): **Autenticación básica habilitada:** El dashboard está protegido mediante el middleware `auth-basic@file` definido en `dynamic/middlewares.yml`.
```yaml ### Configurar contraseña
labels:
- "traefik.http.routers.traefik.middlewares=traefik-auth"
- "traefik.http.middlewares.traefik-auth.basicauth.users=admin:$$apr1$$<hash>"
```
Generar hash (htpasswd): 1. Genera el hash bcrypt:
```bash ```bash
# Linux/macOS docker run --rm httpd:alpine htpasswd -nbB admin tu_password_segura
htpasswd -nb admin 'TuPassword'
# PowerShell con OpenSSL (alternativa)
# openssl passwd -apr1 TuPassword
``` ```
2. Edita `dynamic/middlewares.yml` línea 35 y reemplaza el hash de ejemplo:
```yaml
auth-basic:
basicAuth:
users:
- "admin:$2y$05$tu_hash_generado_aqui"
```
3. Guarda el archivo. Traefik recargará automáticamente en ~10 segundos (no requiere reinicio).
**Usuario por defecto:** `admin` (cambia el hash según tu contraseña)
## Exponer Servicios Detrás de Traefik ## Exponer Servicios Detrás de Traefik
Conecta tus servicios a la red `proxy` y añade labels. Ejemplo: Portainer Conecta tus servicios a la red `proxy` y añade labels. Ejemplo: Portainer

View File

@@ -24,9 +24,8 @@ services:
- "traefik.http.routers.traefik.tls=true" - "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.tls.certresolver=letsencrypt" - "traefik.http.routers.traefik.tls.certresolver=letsencrypt"
- "traefik.http.routers.traefik.service=api@internal" - "traefik.http.routers.traefik.service=api@internal"
# Opcional: Autenticación básica # Autenticación básica (usa middleware del archivo dynamic/middlewares.yml)
# - "traefik.http.routers.traefik.middlewares=traefik-auth" - "traefik.http.routers.traefik.middlewares=auth-basic@file"
# - "traefik.http.middlewares.traefik-auth.basicauth.users=admin:$$apr1$$..."
networks: networks:
proxy: proxy:

View File

@@ -6,6 +6,29 @@ Este directorio contiene configuración que Traefik recarga automáticamente sin
- **middlewares.yml**: Middlewares reutilizables (headers seguridad, rate limit, auth, etc.) - **middlewares.yml**: Middlewares reutilizables (headers seguridad, rate limit, auth, etc.)
## Autenticación Básica
El middleware `auth-basic` está **habilitado por defecto** para proteger el dashboard de Traefik.
### Configurar tu contraseña
1. Genera hash bcrypt:
```bash
docker run --rm httpd:alpine htpasswd -nbB admin tu_password
```
2. Copia el hash completo (después de `admin:`)
3. Edita `middlewares.yml` línea 35:
```yaml
auth-basic:
basicAuth:
users:
- "admin:$2y$05$HASH_GENERADO_AQUI"
```
4. Guarda → recarga automática en ~10 segundos
## Uso ## Uso
### Aplicar middleware a un servicio ### Aplicar middleware a un servicio

View File

@@ -29,11 +29,11 @@ http:
- "10.0.0.0/8" - "10.0.0.0/8"
- "192.168.0.0/16" - "192.168.0.0/16"
# Autenticación básica (genera hash con: htpasswd -nb usuario password) # Autenticación básica (genera hash con: docker run --rm httpd:alpine htpasswd -nbB admin tu_password)
# auth-basic: auth-basic:
# basicAuth: basicAuth:
# users: users:
# - "admin:$apr1$..." - "admin:$2y$05$example_hash_CHANGE_THIS" # CAMBIA ESTE HASH
# Redirect www a root # Redirect www a root
redirect-www: redirect-www: