This commit is contained in:
parent
c03a36f04c
commit
691d22a09f
1 changed files with 152 additions and 0 deletions
152
content/notes/traefik/traefik.md
Normal file
152
content/notes/traefik/traefik.md
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
---
|
||||||
|
title: "Traefik"
|
||||||
|
date: 2025-04-09T12:02:34+02:00
|
||||||
|
tags:
|
||||||
|
- 100DaysToOffload
|
||||||
|
draft: true
|
||||||
|
author: "Colmaris"
|
||||||
|
description: "Jour 015/100 du défi 100DaysToOffLoad."
|
||||||
|
toc: true
|
||||||
|
---
|
||||||
|
Compilation d'infos utiles sur Traefik.
|
||||||
|
|
||||||
|
## Fichiers
|
||||||
|
|
||||||
|
Les fichiers de confs se trouvent sur ma [forge]() git.
|
||||||
|
|
||||||
|
## Identifiant de connexion
|
||||||
|
|
||||||
|
L’identifiant de connexion se présente sous la forme d’une ligne de texte à ajouter tel quel dans le fichier `traefik_auth_file`, contenant le nom d’utilisateur et le mot de passe qui sera chiffré avec openssl. Dans le répertoire `/traefik/secrets`.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
openssl passwd -apr1 mon_mot_de_passe
|
||||||
|
$apr1$89eqM5Ro$CxaFELthUKV21DpI3UTQO.
|
||||||
|
```
|
||||||
|
|
||||||
|
Copier ensuite l'identifiant/mot de passe dans le fichier `/traefik/secrets` :
|
||||||
|
|
||||||
|
```shell
|
||||||
|
user:$apr1$89eqM5Ro$CxaFELthUKV21DpI3UTQO.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration TLS
|
||||||
|
|
||||||
|
Dans le répertoire `/traefik/config` ajouter un fichier `tls.yml`. Il s’agit d’une configuration classique, j’utilise les ciphers autorisés dans la configuration par defaut, avec une version de TLS minimum en 1.2 et je force l’utilisation de TLSv1.3.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tls:
|
||||||
|
options:
|
||||||
|
default:
|
||||||
|
minVersion: VersionTLS12
|
||||||
|
sniStrict: true
|
||||||
|
cipherSuites:
|
||||||
|
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 # TLS 1.2
|
||||||
|
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 # TLS 1.2
|
||||||
|
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 # TLS 1.2
|
||||||
|
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 # TLS 1.2
|
||||||
|
- TLS_AES_256_GCM_SHA384 # TLS 1.3
|
||||||
|
- TLS_CHACHA20_POLY1305_SHA256 # TLS 1.3
|
||||||
|
- TLS_FALLBACK_SCSV # TLS FALLBACK
|
||||||
|
curvePreferences:
|
||||||
|
- secp521r1
|
||||||
|
- secp384r1
|
||||||
|
- X25519
|
||||||
|
- CurveP521
|
||||||
|
- CurveP384
|
||||||
|
- CurveP256
|
||||||
|
modern:
|
||||||
|
minVersion: VersionTLS13
|
||||||
|
```
|
||||||
|
|
||||||
|
## Les middlewares
|
||||||
|
|
||||||
|
Par souci de compréhension j'utilise un fichier par middleware. Ils sont placés dans le dossier `/traefik/config/nom-middleware.yml`.
|
||||||
|
|
||||||
|
### Headers et HSTS
|
||||||
|
|
||||||
|
Nom du fichier : config.yml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
hsts-headers:
|
||||||
|
headers:
|
||||||
|
frameDeny: true
|
||||||
|
browserXssFilter: true
|
||||||
|
contentTypeNosniff: true
|
||||||
|
stsIncludeSubdomains: true
|
||||||
|
stsPreload: true
|
||||||
|
stsSeconds: 31536000
|
||||||
|
forceStsHeader: true
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compression
|
||||||
|
|
||||||
|
Compression en GZIP, nom du fichier: compression.yml.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
http:
|
||||||
|
middlewares:
|
||||||
|
compression:
|
||||||
|
compress:
|
||||||
|
excludedContentTypes:
|
||||||
|
- "text/event-stream"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Docker compose commenté
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
networks:
|
||||||
|
traefik:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
services:
|
||||||
|
traefik:
|
||||||
|
image: traefik:banon
|
||||||
|
restart: unless-stopped
|
||||||
|
container_name: traefik
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
labels:
|
||||||
|
- traefik.enable=true # J'active traefik
|
||||||
|
- traefik.docker.network=traefik # j'indique le réseau pour l'exposition du conteneur
|
||||||
|
- traefik.http.middlewares.admin-auth.basicauth.usersfile=/secrets/traefik_auth_file # fichier contenant l'auhentification pour l'accès au dashboard
|
||||||
|
- traefik.http.routers.traefik.rule=Host(`traffic.${DOMAIN}`) # url d'accès
|
||||||
|
- traefik.http.routers.traefik.entrypoints=https # port d'écoute utilisé
|
||||||
|
- traefik.http.routers.traefik.tls=true # chiffrage
|
||||||
|
- traefik.http.routers.traefik.service=api@internal # service propre à traefik pour le dashboard
|
||||||
|
- traefik.http.routers.traefik.tls.certresolver=le # Let's encrypt comme resolveur de certificat
|
||||||
|
- traefik.http.routers.traefik.middlewares=admin-auth # activation de l'authentification via le fichier défini plus haut
|
||||||
|
- traefik.http.services.traefik.loadbalancer.server.port=8080 # port d'écoute du dashbord non exposé
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro # écoute de l'api docker
|
||||||
|
- /mnt/nas/voljin/volumes/traefik:/certificates # stockage des certificats
|
||||||
|
- ./secrets:/secrets:ro # stockage des mots de passes
|
||||||
|
- ./config:/config:ro # configuration dynamique
|
||||||
|
- ./logs:/logs # enregistrement des logs.
|
||||||
|
command:
|
||||||
|
# ------------------------------------------- providers Docker
|
||||||
|
- --providers.docker
|
||||||
|
- --providers.docker.exposedbydefault=false
|
||||||
|
# ------------------------------------------- Providers Fichier
|
||||||
|
- --providers.file.directory=/config/
|
||||||
|
- --providers.file.watch=true
|
||||||
|
# ------------------------------------------- Ports
|
||||||
|
- --entrypoints.http.address=:80
|
||||||
|
- --entrypoints.https.address=:443
|
||||||
|
# ------------------------------------------- Redirection vers https
|
||||||
|
- --entrypoints.http.http.redirections.entrypoint.to=https
|
||||||
|
- --entrypoints.http.http.redirections.entrypoint.scheme=https
|
||||||
|
# ------------------------------------------- Configuration SSL
|
||||||
|
- --certificatesresolvers.le.acme.email=${TRAEFIKEMAIL}
|
||||||
|
- --certificatesresolvers.le.acme.storage=/certificates/acme.json
|
||||||
|
- --certificatesresolvers.le.acme.tlschallenge=true
|
||||||
|
# ------------------------------------------- Configuration traefik
|
||||||
|
- --global.sendanonymoususage=false
|
||||||
|
- --accesslog=true
|
||||||
|
- --log.level=INFO
|
||||||
|
- --log.filePath=/logs/traefik.log
|
||||||
|
- --api
|
||||||
|
networks:
|
||||||
|
- traefik
|
||||||
|
```
|
Loading…
Add table
Reference in a new issue