No matter what I try, I cannot get Traefik working with Moodle. I set up a docker compose with Traefik and Alpine-Moodle.
All I get is a Gateway Timeout error. I have made sure Traefik and Alpine-Moodle are in the same docker network and I am able to CURL the Alpine-Moodle site just fine from the Traefik container.
I also have tried using alpine-php-nginx with a basic hello proxied trough Traefik, but without success. I have other containers proxied trough Traefik that work fine, so I doubt the problem is in my Traefik configuration.
version: "3.5"
services:
traefik:
container_name: traefik
image: "traefik:latest"
command:
- --providers.docker
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/etc/traefik:/etc/traefik"
networks:
- web
labels:
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`dash.mydomain.com`)"
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.services.dashboard.loadbalancer.server.port=8080"
- "traefik.http.routers.dashboard.service=dashboard"
- "traefik.http.routers.dashboard.tls.certresolver=production"
networks:
web:
name: web
driver: bridge
version: '2'
services:
postgres:
image: postgres:alpine
restart: unless-stopped
networks:
- default
environment:
- POSTGRES_PASSWORD=moodle
- POSTGRES_USER=moodle
- POSTGRES_DB=moodle
volumes:
- postgres:/var/lib/postgresql/data
moodle:
image: jimsihk/alpine-moodle
build: .
restart: unless-stopped
networks:
- default
- web
labels:
- "traefik.enable=true"
- "traefik.http.routers.moodle.rule=Host(`mydomain.com`)"
- "traefik.http.routers.moodle.entrypoints=websecure"
- "traefik.http.routers.moodle.tls=true"
- "traefik.http.routers.moodle.tls.certresolver=production"
- "traefik.http.routers.moodle.service=moodleapp"
- "traefik.http.services.moodleapp.loadbalancer.server.port=8080"
environment:
- LANG=en_US.UTF-8
- LANGUAGE=en_US:en
- SITE_URL=https://mydomain.com
- DB_TYPE=pgsql
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=moodle
- DB_USER=moodle
- DB_PASS=moodle
- DB_PREFIX=mdl_
- SSLPROXY=true
- [email protected]
- MOODLE_LANGUAGE=en
- MOODLE_SITENAME=New-Site
- MOODLE_USERNAME=moodleuser
- MOODLE_PASSWORD=PLEASE_CHANGEME
- SMTP_HOST=smtp.gmail.com
- SMTP_PORT=587
- [email protected]
- SMTP_PASSWORD=your_password \
- SMTP_PROTOCOL=tls
- MOODLE_MAIL_NOREPLY_ADDRESS=noreply@localhost
- MOODLE_MAIL_PREFIX=[moodle]
- SESSION_CACHE_TYPE=database
- SESSION_CACHE_HOST=postgres
- SESSION_CACHE_PORT=5432
- SESSION_CACHE_PREFIX=mdl
- AUTO_UPDATE_MOODLE=true
ports:
- 8080:8080
volumes:
- moodledata:/var/www/moodledata
- moodlehtml:/var/www/html
depends_on:
- postgres
volumes:
postgres: null
moodledata: null
moodlehtml: null
networks:
default:
internal: true
web:
external: true
global:
checkNewVersion: true
sendAnonymousUsage: false
api:
dashboard: true
insecure: true
entryPoints:
web:
address: :80
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: :443
certificatesResolvers:
staging:
acme:
email: [email protected]
storage: /etc/traefik/certs/acme.json
caServer: "https://acme-staging-v02.api.letsencrypt.org/directory"
httpChallenge:
entryPoint: web
production:
acme:
email: [email protected]
storage: /etc/traefik/certs/acme.json
caServer: "https://acme-v02.api.letsencrypt.org/directory"
httpChallenge:
entryPoint: web
providers:
docker:
exposedByDefault: false
file:
directory: /etc/traefik
watch: true