From 368f6d115f910b9887ff1203b62bb1efc6cff643 Mon Sep 17 00:00:00 2001 From: Didier 'OdyX' Raboud Date: Wed, 26 Jun 2019 15:08:12 +0200 Subject: [PATCH] Allow HTTPS for traefik --- README.md | 1 + config.docker-template.php | 7 ++++++- traefik.yml | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 989ffe1e5aa..b4f7374b9ef 100755 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ You can change the configuration of the docker images by setting various environ | `MOODLE_DOCKER_WEB_PORT` | no | any integer value | 8000 | The port number for web. If set to 0, no port is used | | `MOODLE_DOCKER_SELENIUM_VNC_PORT` | no | any integer value | not set | If set, the selenium node will expose a vnc session on the port specified | | `MOODLE_DOCKER_TRAEFIK` | no | any value | not set | If set, integrate the docker containers in traefik | +| `MOODLE_DOCKER_TRAEFIK_HTTPS` | no | any value | not set | If set, use an https url in traefik | ## Advanced usage diff --git a/config.docker-template.php b/config.docker-template.php index b15865485dd..9037419eba3 100755 --- a/config.docker-template.php +++ b/config.docker-template.php @@ -19,7 +19,12 @@ } $CFG->wwwroot = "http://{$host}"; $port = getenv('MOODLE_DOCKER_WEB_PORT'); -if (!empty($port) && empty(getenv('MOODLE_DOCKER_TRAEFIK'))) { +if (!empty(getenv('MOODLE_DOCKER_TRAEFIK'))) { + if (!empty(getenv('MOODLE_DOCKER_TRAEFIK_HTTPS'))) { + $CFG->sslproxy = true; + $CFG->wwwroot = "https://{$host}"; + } +} else if (!empty($port)) { $CFG->wwwroot .= ":{$port}"; } $CFG->dataroot = '/var/www/moodledata'; diff --git a/traefik.yml b/traefik.yml index d151720d261..da7ec4926c7 100644 --- a/traefik.yml +++ b/traefik.yml @@ -3,6 +3,7 @@ services: webserver: environment: MOODLE_DOCKER_TRAEFIK: "${MOODLE_DOCKER_TRAEFIK}" + MOODLE_DOCKER_TRAEFIK_HTTPS: "${MOODLE_DOCKER_TRAEFIK_HTTPS}" labels: - "traefik.enable=true" - "traefik.frontend.rule=Host:${MOODLE_DOCKER_WEB_HOST}"