- Modifié
Plusieurs choses qui ne vont pas ici :
- Tu ne défini pas de conf pour traefik !
- Tu n'as pas besoin de mapper les ports des container avec ceux de l'hôte.
- Tes containers doivent être dans le réseau traefik_proxy.
- Le port défini dans tes labels doivent dorrespondre au port interne du container.
- Tu devrais définir tes headers dans le fichier de conf de traefik, ça allègerai ton docker-compose !
`
Après relecture, c'est surprenant.. tu as des services bien configurés (portainer) et d'autres pas du tout !
Exemple de service OK :
wordpress:
image: wordpress:latest
container_name: wordpress
restart: always
depends_on:
- wordpress_db
networks:
- traefik_proxy
- internal
environment:
- WORDPRESS_DB_PASSWORD=${WORDPRESS_DB_PASSWORD}
volumes:
- wp_conf_upload_php:/usr/local/etc/php/conf.d/uploads.ini
- wp_app:/var/www/html # Full wordpress project
networks:
- traefik_proxy
labels:
- "traefik.enable=true"
- "traefik.frontend.rule=Host:toto3.${DOMAINNAME}"
- "traefik.port=80"
- "traefik.docker.network=traefik_proxy"
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.frontend.headers.STSSeconds=315360000"
- "traefik.frontend.headers.browserXSSFilter=true"
- "traefik.frontend.headers.contentTypeNosniff=true"
- "traefik.frontend.headers.forceSTSHeader=true"
- "traefik.frontend.headers.SSLHost=richardantoine.fr"
- "traefik.frontend.headers.STSIncludeSubdomains=true"
- "traefik.frontend.headers.STSPreload=true"
- "traefik.frontend.headers.frameDeny=true"
Exemple de fichier de conf de traefik:
defaultEntryPoints = ["https","http"]
[api]
entryPoint = "traefik"
dashboard = true
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[entryPoints.traefik]
address = ":8080"
[entryPoints.traefik.auth.basic]
users = ["zer:$apr1$Gj3CFGpe$2j.Yr0fF8lcd2SJOl97Pu1"]
[acme]
email = "me@mydomain.tld"
storage = "/etc/traefik/acme/acme.json"
entryPoint = "https"
onHostRule = true
onDemand = false
[acme.httpChallenge]
entryPoint = "http"
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "mydomain.tld"
watch = true
exposedbydefault = false
Il convient d'enregistrer ça dans un fichier traefik.toml et de le mapper avec le container traefik.