Hello everyone,
I am trying to set up traefik as a reverse proxy handling https for an owncloud instance. Both should be run in docker using two docker-compose files.
So far I was able to start both containers and I am able to log into the traefik dashboard successfully. However, with the owncloud container running, if I try to connect to it using the configured subdomain I keep getting a 404. Traefik seems to find the two other services owncloud relies on, redis and mariadb, but not the owncloud-server itself: it does not show up on the dashboard as an http service. The configurations are further below. All of the environment variables are stored in respective .env files are according to traefik's log seem to expand properly. HTTP_PORT is also set to 8080 for simplicity. Any input is appreciated.
Cheers,
Saph.
traefik's docker-compose.yml
version: '3'
services:
traefik:
container_name: traefik
image: traefik:latest
command:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --providers.docker
- --api
- --certificatesresolvers.le.acme.email=saphieron@gmail.com
- --certificatesresolvers.le.acme.storage=/acme.json
- --certificatesresolvers.le.acme.tlschallenge=true
- --log.filePath=/traefik.log
- --log.level=DEBUG
networks:
- web
- internal
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /etc/localtime:/etc/localtime:ro
- "./acme.json:/acme.json"
- "./traefik.log:/traefik.log"
restart: unless-stopped
security_opt:
- no-new-privileges:true
environment:
- TRAEFIK_ADMIN=${TRAEFIK_ADMIN}
labels:
- "traefik.docker.network=web"
# dashboard
- "traefik.http.routers.traefik.rule=Host(`traefik.my.domain`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.middlewares=admin"
- "traefik.http.routers.traefik.tls.certresolver=le"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.middlewares.admin.basicauth.users=${TRAEFIK_ADMIN}"
# global redirect to https
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
# middleware redirect
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
networks:
web:
external: true
internal:
Owncloud's docker-compose.yml
version: "3"
volumes:
files:
driver: local
mysql:
driver: local
redis:
driver: local
services:
owncloud:
image: owncloud/server:${OWNCLOUD_VERSION}
container_name: owncloud_server
restart: unless-stopped
ports:
- ${HTTP_PORT}:8080
depends_on:
- mariadb
- redis
environment:
- OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
- OWNCLOUD_DB_TYPE=mysql
- OWNCLOUD_DB_NAME=owncloud
- OWNCLOUD_DB_USERNAME=${OWNCLOUD_DB_ADMIN}
- OWNCLOUD_DB_PASSWORD=${OWNCLOUD_DB_PASSWORD}
- OWNCLOUD_DB_HOST=mariadb
- OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
- OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
- OWNCLOUD_MYSQL_UTF8MB4=true
- OWNCLOUD_REDIS_ENABLED=true
- OWNCLOUD_REDIS_HOST=redis
networks:
- web
- internal
labels:
- "traefik.enable=true"
- "traefik.docker.network=web"
- "traefik.http.services.owncloud.loadbalancer.server.port=8080"
- "traefik.http.routers.owncloud.rule=Host(`owncloud.my.domain`)"
- "traefik.http.routers.owncloud.secure.rule=Host(`owncloud.my.domain`)"
healthcheck:
test: ["CMD", "/usr/bin/healthcheck"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- files:/mnt/data
- /var/run/docker.sock:/var/run/docker.sock:root
mariadb:
image: mariadb:10.5
container_name: owncloud_mariadb
restart: always
environment:
- MYSQL_ROOT_PASSWORD=${OWNCLOUD_MARIA_DB_ROOTPW}
- MYSQL_USER=${OWNCLOUD_MARIA_DB_USER}
- MYSQL_PASSWORD=${OWNCLOUD_MARIA_DB_PASSWORD}
- MYSQL_DATABASE=owncloud
command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"]
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=${OWNCLOUD_MARIA_DB_ROOTPW}"]
interval: 10s
timeout: 5s
retries: 5
#volumes:
#- mysql:/var/lib/mysql
redis:
image: redis:6
container_name: owncloud_redis
restart: always
command: ["--databases", "1"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- redis:/datamariadb
networks:
web:
external: true
internal: