I'm new to Traefik and Docker and trying to set up an environment to learn, so I'd appreciate some patience with any silly questions I might have.
I'm trying to set up a Traefik container that routes to two web servers on two different hosts. I'm having trouble adding the WordPress site as a service in Traefik, so that it can then route and establish the connection between WordPress and Traefik, as well as the connection between Traefik and the WordPress containers.
Is there anything obvious that I'm missing or any clear mistake that you see? It feels like I've tried everything but just can't get it to work. Let me know if you need any more information about my environment! Would appreciate any help!
Here are my config files:
docker_compose.yml:
networks:
wordpress-network:
external: true
traefik-network:
external: true
volumes:
mysql-data:
wordpress-data:
services:
mysql:
image: ${WORDPRESS_MYSQL_IMAGE_TAG}
volumes:
- mysql-data:/var/lib/mysql
environment:
MYSQL_DATABASE: ${WORDPRESS_DB_NAME}
MYSQL_USER: ${WORDPRESS_DB_USER}
MYSQL_PASSWORD: ${WORDPRESS_DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${WORDPRESS_DB_ADMIN_PASSWORD}
networks:
- wordpress-network
restart: unless-stopped
wordpress:
image: ${WORDPRESS_IMAGE_TAG}
volumes:
- wordpress-data:${DATA_PATH}
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_PORT_NUMBER: 3306
WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
WORDPRESS_TABLE_PREFIX: ${WORDPRESS_TABLE_PREFIX}
WORDPRESS_BLOG_NAME: ${WORDPRESS_BLOG_NAME}
WORDPRESS_FIRST_NAME: ${WORDPRESS_ADMIN_NAME}
WORDPRESS_LAST_NAME: ${WORDPRESS_ADMIN_LASTNAME}
WORDPRESS_USERNAME: ${WORDPRESS_ADMIN_USERNAME}
WORDPRESS_PASSWORD: ${WORDPRESS_ADMIN_PASSWORD}
networks:
- wordpress-network
- traefik-network
labels:
- "traefik.enable=true"
- "traefik.http.routers.wordpress.rule=Host(`${WORDPRESS_HOSTNAME}`)"
- "traefik.http.routers.wordpress.service=wordpress"
- "traefik.http.routers.wordpress.entrypoints=web"
- "traefik.http.services.wordpress.loadbalancer.server.port=80"
- "traefik.docker.network=traefik-network"
restart: unless-stopped
traefik:
image: ${TRAEFIK_IMAGE_TAG}
command:
- "--log.level=${TRAEFIK_LOG_LEVEL}"
- "--accesslog=true"
- "--api.dashboard=true"
- "--api.insecure=true"
- "--entryPoints.web.address=:80"
- "--providers.docker=true"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.exposedByDefault=false"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- traefik-network
ports:
- "80:80"
- "8080:8080"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`${TRAEFIK_HOSTNAME}`)"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.entrypoints=web"
restart: unless-stopped
docker-compose-traefik.yml:
traefik:
image: ${TRAEFIK_IMAGE_TAG}
command:
- "--log.level=${TRAEFIK_LOG_LEVEL}"
- "--accesslog=true"
- "--api.dashboard=true"
- "--api.insecure=true"
- "--entryPoints.web.address=:80"
- "--providers.docker=true"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.exposedByDefault=false"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- traefik-network
ports:
- "80:80"
- "8080:8080"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`${TRAEFIK_HOSTNAME}`)"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.entrypoints=web"
restart: unless-stopped
docker-compose-wordpress.yml:
version: '3'
networks:
traefik:
external: true
wordpress:
external: true
volumes:
db_data:
services:
wordpress:
image: wordpress
labels:
- "traefik.enable=true"
- "traefik.http.routers.wordpress.rule=Host(`www.proxmoxpojkarna.se`)"
- "traefik.http.routers.wordpress.entrypoints=web"
- "traefik.http.services.wordpress.loadbalancer.server.port=80"
environment:
- WORDPRESS_DB_HOST=mysql
- WORDPRESS_DB_USER=root
- WORDPRESS_DB_PASSWORD=password
depends_on:
- mysql
networks:
- traefik
- wordpress
mysql:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=wordpress
volumes:
- db_data:/var/lib/mysql
networks:
- wordpress