2026-03-19 20:04:30theophile:
tranduction et ajout d'info
services hng/traefik.md ..
@@ 1,57 1,76 @@
# Traefik
-
**traefik** serves as our reverse-proxy and let's encrypt certificat issuer.
+
**traefik** est notre reverse-proxy et émetteur de certificats Let's Encrypt.
-
For each docker service, we create an **external network** (usually named after the service it serves) and add it to the **traefik**'s `docker-compose.yml` file, in two locations:
+
## Etiquettes (`labels`)
+
+
Pour ajouter la gestion traefik à un container, il nous faut:
+
+
- créer un réseau pour le service
+
- utiliser `expose` à la place de `ports` pour les ports ouverts du container.
+
- on ajouter `labels` qui lie le réseau docker,
+
+
```yaml
+
networks:
+
- service
+
expose:
+
- 3001
+
labels:
+
- "traefik.enable=true" # Enable reverse-proxy for this service
+
- "traefik.docker.network=service" # The external docker network
+
- "traefik.http.routers.service.rule=Host(`service.happyngreen.fr`)" # The domain name.
- "traefik.http.services.service-secure.loadbalancer.server.port=3001" # The exposed port.
+
+
```
+
+
> [!IMPORTANT]
+
> un router **traefik** peut avoir n'importe quel nom, y compris celui de service ou du réseau. `uptime-kuma`, `docker-uptime-kuma`, etc.
+
+
Une fois que votre `docker-compose.yml` est bon (volumes, port, network, container_name, etc), lancer le pour créer le network.
+
Alternativement, vous pouvez utiliser:
+
+
```bash
+
docker network create service_name
+
```
+
+
## Réseau → Traefik
+
+
Pour chaque services docker compose, nous crééons un **réseau** (nommé d'après le service qui l'utilise) et nous l'ajoutons au `docker-compose.yml` de **traefik**, à deux endroits précis:
```yaml
networks:
-
# → 1st Entry of traefik-managed networks
+
# → 1er endroit
traefik:
-
mail:
-
name: mailu_mail
-
external: true
+
service:
+
name: service # ← le nom du réseau
+
external: true # externe car il est créer quand on lance le container
# etc...
services:
traefik:
# (...)
networks:
-
# → 2nd Entry of the networks
+
# → 2eme endroit
traefik:
-
mail:
+
service: # ← le nom du réseau
# etc...
```
-
We then have to rebuild restart (?) **traefik**.
-
-
## Labels
-
-
To add traefik handling to a service, we use `expose` instead of `port` to set the port, and use labels:
-
-
```yaml
-
expose:
-
- 3001
-
# This our default label setup.
-
labels:
-
- "traefik.enable=true" # Enable reverse-proxy for this service
-
- "traefik.docker.network=uptime-kuma" # The external docker network
-
- "traefik.http.routers.uptime-kuma.rule=Host(`status.happyngreen.fr`)" # The domain name.
- "traefik.http.services.uptime-kuma-secure.loadbalancer.server.port=3001" # The exposed port.
+
Ensuit, lancer la commandes suivantes pour relancer le container avec les nouveaux réseaus docker.
+
```bash
+
docker compose up -d
```
-
> [!IMPORTANT]
-
> A **traefik** router can have any name. `uptime-kuma`, `docker-uptim-kuma`, etc.
-
+
## Troubleshooting
-
## Remove `le-stg` certificats
+
### Retirer un certificat `le-stg`
-
Let's Encrypt certificates are stored in `$CONFIG/cert/acme.json`. You can remove the relevant lines in the `le-stg` section, then restart traefik.
+
Les certificats Let's Encrypt sont stocker dans `$CONFIG/cert/acme.json`. Vous pouvez retirer les retirer en supprimant les lignes concerné dans la section `le-stg`. Il faut ensuite redémarrer traefik → `docker compose restart`.