estoy montando un sitio web con docker y traefik, en el proyecto tengo 5 contenedores.
Traefik
Wordpress
mysql
nginx
phpmyadmin
cuando ejecuto el comando docker-compose up -d
todos los contenedores se levantan sin ningun problema, sin embargo tengo activada la api de traefik pero no logro entrar al dashboard ya que me arroja un error 404
.
este es mi archivo docker-compose
version: "3.7"
services:
reverse-proxy:
image: traefik:v2.1
container_name: traefik
labels:
- traefik.http.routers.api.rule=Host(`traefik.midominio.com`)
- traefik.http.routers.api.entrypoints=websecure
- traefik.http.routers.api.tls.certresolver=myresolver
- traefik.port=8080
ports:
- 443:443
- 80:80
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik.yml:/traefik.yml
- ./letsencrypt:/letsencrypt
networks:
- web
db:
image: mysql:5.7.22
container_name: db
restart: unless-stopped
environment:
MYSQL_DATABASE: "${MYSQL_DATABASE}"
MYSQL_USER: "${MYSQL_USER}"
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
labels:
- traefik.enable=true
- traefik.port=3306
volumes:
- ./mysql:/var/lib/mysql
networks:
- web
wp:
build:
context: .
dockerfile: Dockerfile
container_name: wp
labels:
- traefik.enable=true
- traefik.http.routers.wp.rule=Host(`midominio.com`)
- traefik.http.routers.wp.entrypoints=websecure
- traefik.http.routers.wp.tls.certresolver=myresolver
- traefik.port=9000
depends_on:
- db
volumes:
- ./src:/var/www/html
environment:
WORDPRESS_DB_HOST: "${WORDPRESS_DB_HOST}"
WORDPRESS_DB_NAME: "${WORDPRESS_DB_NAME}"
WORDPRESS_DB_USER: "${WORDPRESS_DB_USER}"
WORDPRESS_DB_PASSWORD: "${WORDPRESS_DB_PASSWORD}"
networks:
- web
nginx:
image: nginx:alpine
container_name: wp-nginx
depends_on:
- wp
labels:
- traefik.port=80
volumes:
- ./conf.d:/etc/nginx/conf.d
- ./conf.d/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
- ./src:/var/www/html
networks:
- web
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
restart: always
environment:
PMA_HOST: ${PMA_HOST}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
labels:
- traefik.enable=true
- traefik.http.routers.phpmyadmin.rule=Host(`pa.midominio.com`)
- traefik.http.routers.phpmyadmin.entrypoints=websecure
- traefik.http.routers.phpmyadmin.tls.certresolver=myresolver
- traefik.port=80
networks:
- web
networks:
web:
driver: "bridge"
y este es mi archivo traefik.yml
# DEFINE EL PROVEEDOR DOCKER
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
api:
dashboard: true
debug: true
# DEFINE LOS PUNTOS DE ENTRADA DE TRAEFIK
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
dashboard:
address: ":8080"
# REDIRIGE LAS PETICIONES HTTP A HTTPS
http:
routers:
router0:
rule: "Host(`midominio.com`)"
entryPoints:
- web
middlewares:
- https_redirect
service: wp
# GENERA CERTIFICADOS SSL PARA LOS CONTENEDORES DE DOCKER
certificatesResolvers:
myresolver:
acme:
email: [email protected]
storage: ./letsencrypt/acme.json
httpChallenge:
entryPoint: web
# MIDDLEWARES GLOBALES DE TRAEFIK
middlewares:
https_redirect:
redirectScheme:
scheme: https
permanent: true
así lucen mis contenedores:
db docker-entrypoint.sh mysqld Up 3306/tcp
phpmyadmin /docker-entrypoint.sh apac ... Up 80/tcp
traefik /entrypoint.sh traefik Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:8080->8080/tcp
wp docker-entrypoint.sh apach ... Up 80/tcp, 9000/tcp
wp-nginx /docker-entrypoint.sh ngin ... Up 80/tcp
Este es el log de traefik.
traefik | time="2020-07-24T15:40:31Z" level=info msg="Configuration loaded from file: /traefik.yml"
estoy utilizando traefik en su versiòn 2.1
, he visto la documentaciòn pero no logro activar la api, espero puedan ayudarme, muchas gracias.