- Modifié
Bonjour,
J'utilise Traefik comme reverse proxy (au lieu de l'image de jrcs) pour la prise en charge du wildcard let's encrypt. Je voudrais que traefik redirige le trafic vers plusieurs docker qui tournent sur le port 80. Naturellement, j'ai exposé le port 80 de chaque docker vers un autre port pour l'utiliser dans traefik mais cela ne fonctionne pas. Comment faire ?
Voici mon docker-compose :
version: '3.6'
services:
traefik:
hostname: traefik
image: traefik:latest
container_name: traefik
restart: always
domainname: ${DOMAINNAME}
networks:
- default
- traefik_proxy
ports:
- "80:80"
- "443:443"
- "8080:8080"
environment:
- OVH_ENDPOINT=${OVH_ENDPOINT}
- OVH_APPLICATION_KEY=${OVH_APPLICATION_KEY}
- OVH_APPLICATION_SECRET=${OVH_APPLICATION_SECRET}
- OVH_CONSUMER_KEY=${OVH_CONSUMER_KEY}
labels:
- "traefik.enable=true"
- "traefik.backend=traefik" # Utile pour le load balancing
# L'adresse sur laquelle l'utilisateur accède à l'application
- "traefik.frontend.rule=Host:toto.${DOMAINNAME}, www.toto.${DOMAINNAME}"
- "traefik.port=8080" # Le port de l'application dans le conteneur
- "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"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik:/etc/traefik
- shared:/shared
deploy:
replicas: 6
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
portainer:
image: portainer/portainer
container_name: portainer
restart: always
command: -H unix:///var/run/docker.sock
# ports:
# - "XXXX:9000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer-data:/data
- shared:/shared
environment:
- TZ=${TZ}
networks:
- traefik_proxy
labels:
- "traefik.enable=true"
- "traefik.backend=portainer"
- "traefik.frontend.rule=Host:toto1.${DOMAINNAME},www.toto2.${DOMAINNAME}"
- "traefik.port=9000"
- "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"
wordpress:
image: wordpress:latest
container_name: wordpress
restart: always
depends_on:
- wordpress_db
networks:
- traefik_proxy
- internal
ports:
- "7006:80"
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
labels:
- "traefik.enable=true"
- "traefik.backend=wordpress"
- "traefik.frontend.rule=Host:toto3.${DOMAINNAME}"
- "traefik.port=7006"
- "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"
wordpress_db:
image: mariadb:latest
container_name: wordpress_db
restart: always
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
networks:
- internal
volumes:
- wp_data:/docker-entrypoint-initdb.d
labels:
- traefik.enable=true
nextcloud:
container_name: nextcloud
restart: always
image: linuxserver/nextcloud
volumes:
- nextcloud:/config
- shared_data:/data
- shared:/shared
# ports:
# - "XXXX:443"
environment:
- PUID=${PUID}
- PGID=${PGID}
networks:
- traefik_proxy
labels:
- "traefik.enable=true"
- "traefik.backend=nextcloud"
- "traefik.frontend.rule=Host:toto4.${DOMAINNAME}"
- "traefik.port=443"
- "traefik.protocol=https"
- "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=example.com"
- "traefik.frontend.headers.STSIncludeSubdomains=true"
- "traefik.frontend.headers.STSPreload=true"
- "traefik.frontend.headers.frameDeny=true"
volumes:
traefik:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/traefik
shared:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/shared
organizr:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/organizr
shared_data:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/shared_data
nextcloud:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/nextcloud
podcast_conf:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/podcast
### WORDPRESS ###
wp_app:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/wordpress/app
wp_data:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/wordpress/data
wp_conf_upload_php:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/wordpress/conf
portainer-data:
driver: local
driver_opts:
o: bind
type: none
device: ${USERDIR}/docker/portainer/data
networks:
traefik_proxy:
external:
name: traefik_proxy
internal:
external: false
default:
driver: bridge