From e3788257db015bab313a74e485970e6282f5bde5 Mon Sep 17 00:00:00 2001 From: Crist Date: Mon, 4 Oct 2021 20:14:28 +0800 Subject: [PATCH] Feature: configuration setting `PREVIEW_LMS_BASE` discussion: https://discuss.overhang.io/t/new-settings-variable/1973/4 --- CHANGELOG.md | 2 ++ docs/configuration.rst | 2 +- docs/local.rst | 2 +- tutor/templates/apps/caddy/Caddyfile | 2 +- tutor/templates/apps/nginx/lms.conf | 2 +- tutor/templates/apps/openedx/config/cms.env.json | 2 +- tutor/templates/apps/openedx/config/lms.env.json | 2 +- tutor/templates/apps/openedx/settings/cms/development.py | 2 +- tutor/templates/config.yml | 1 + 9 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index debf333..9055130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Feature] Add configuration setting `PREVIEW_LMS_BASE` for custom preview domain. + ## v12.1.3 (2021-09-28) - [Bugfix] Fix 500 error during user registration. diff --git a/docs/configuration.rst b/docs/configuration.rst index 99a2f5d..14aa173 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -188,7 +188,7 @@ When ``ENABLE_HTTPS`` is ``true``, the whole Open edX platform will be reconfigu The following DNS records must exist and point to your server:: LMS_HOST (e.g: myopenedx.com) - preview.LMS_HOST (e.g: preview.myopenedx.com) + PREVIEW_LMS_HOST (e.g: preview.myopenedx.com) CMS_HOST (e.g: studio.myopenedx.com) Thus, **this feature will (probably) not work in development** because the DNS records will (probably) not point to your development machine. diff --git a/docs/local.rst b/docs/local.rst index c72634e..0a9d109 100644 --- a/docs/local.rst +++ b/docs/local.rst @@ -184,7 +184,7 @@ The containerized web server (`Caddy `__) needs to lis tutor config save --set RUN_CADDY=false --set NGINX_HTTP_PORT=81 -In this example, the nginx container port would be mapped to 81 instead of 80. You must then configure the web proxy on the host. As of v11.0.0, configuration files are no longer provided for automatic configuration of your web proxy. Basically, you should setup a reverse proxy to `localhost:NGINX_HTTP_PORT` from the following hosts: LMS_HOST, preview.LMS_HOST, CMS_HOST, as well as any additional host exposed by your plugins. +In this example, the nginx container port would be mapped to 81 instead of 80. You must then configure the web proxy on the host. As of v11.0.0, configuration files are no longer provided for automatic configuration of your web proxy. Basically, you should setup a reverse proxy to `localhost:NGINX_HTTP_PORT` from the following hosts: LMS_HOST, PREVIEW_LMS_HOST, CMS_HOST, as well as any additional host exposed by your plugins. .. warning:: In this setup, the Nginx HTTP port will be exposed to the world. Make sure to configure your server firewall to block unwanted connections to your server's `NGINX_HTTP_PORT`. Alternatively, you can configure the Nginx container to accept only local connections:: diff --git a/tutor/templates/apps/caddy/Caddyfile b/tutor/templates/apps/caddy/Caddyfile index 9a77c2b..0f33948 100644 --- a/tutor/templates/apps/caddy/Caddyfile +++ b/tutor/templates/apps/caddy/Caddyfile @@ -3,7 +3,7 @@ header_up X-Forwarded-Port {{ 443 if ENABLE_HTTPS else 80 }} } } -preview.{{ LMS_HOST }}{% if not ENABLE_HTTPS %}:80{% endif %} { +{{ PREVIEW_LMS_HOST }}{% if not ENABLE_HTTPS %}:80{% endif %} { reverse_proxy nginx:80 } {{ CMS_HOST }}{% if not ENABLE_HTTPS %}:80{% endif %} { diff --git a/tutor/templates/apps/nginx/lms.conf b/tutor/templates/apps/nginx/lms.conf index f95b930..6b65d89 100644 --- a/tutor/templates/apps/nginx/lms.conf +++ b/tutor/templates/apps/nginx/lms.conf @@ -5,7 +5,7 @@ upstream lms-backend { server { listen 80; - server_name {{ LMS_HOST }} preview.{{ LMS_HOST }}; + server_name {{ LMS_HOST }} {{ PREVIEW_LMS_HOST }}; access_log /var/log/nginx/access.log tutor; client_max_body_size 4M; diff --git a/tutor/templates/apps/openedx/config/cms.env.json b/tutor/templates/apps/openedx/config/cms.env.json index 32aea1b..6bd1aa5 100644 --- a/tutor/templates/apps/openedx/config/cms.env.json +++ b/tutor/templates/apps/openedx/config/cms.env.json @@ -9,7 +9,7 @@ {{ patch("common-env-features", separator=",\n", suffix=",")|indent(4) }} {{ patch("cms-env-features", separator=",\n", suffix=",")|indent(4) }} "CERTIFICATES_HTML_VIEW": true, - "PREVIEW_LMS_BASE": "preview.{{ LMS_HOST }}", + "PREVIEW_LMS_BASE": "{{ PREVIEW_LMS_HOST }}", "ENABLE_COURSEWARE_INDEX": true, "ENABLE_CSMH_EXTENDED": false, "ENABLE_LEARNER_RECORDS": false, diff --git a/tutor/templates/apps/openedx/config/lms.env.json b/tutor/templates/apps/openedx/config/lms.env.json index 15a2b12..045c00c 100644 --- a/tutor/templates/apps/openedx/config/lms.env.json +++ b/tutor/templates/apps/openedx/config/lms.env.json @@ -9,7 +9,7 @@ {{ patch("common-env-features", separator=",\n", suffix=",")|indent(4) }} {{ patch("lms-env-features", separator=",\n", suffix=",")|indent(4) }} "CERTIFICATES_HTML_VIEW": true, - "PREVIEW_LMS_BASE": "preview.{{ LMS_HOST }}", + "PREVIEW_LMS_BASE": "{{ PREVIEW_LMS_HOST }}", "ENABLE_CORS_HEADERS": true, "ENABLE_COURSE_DISCOVERY": true, "ENABLE_COURSEWARE_SEARCH": true, diff --git a/tutor/templates/apps/openedx/settings/cms/development.py b/tutor/templates/apps/openedx/settings/cms/development.py index 349edca..da6824c 100644 --- a/tutor/templates/apps/openedx/settings/cms/development.py +++ b/tutor/templates/apps/openedx/settings/cms/development.py @@ -4,7 +4,7 @@ from cms.envs.devstack import * LMS_BASE = "{{ LMS_HOST }}:8000" LMS_ROOT_URL = "http://" + LMS_BASE -FEATURES["PREVIEW_LMS_BASE"] = "preview." + LMS_BASE +FEATURES["PREVIEW_LMS_BASE"] = "{{ PREVIEW_LMS_HOST }}:8000" {% include "apps/openedx/settings/partials/common_cms.py" %} diff --git a/tutor/templates/config.yml b/tutor/templates/config.yml index cab9dce..4cb6d39 100644 --- a/tutor/templates/config.yml +++ b/tutor/templates/config.yml @@ -20,6 +20,7 @@ RUN_MYSQL: true RUN_REDIS: true RUN_SMTP: true CMS_HOST: "studio.{{ LMS_HOST }}" +PREVIEW_LMS_HOST: "preview.{{ LMS_HOST }}" CONTACT_EMAIL: "contact@{{ LMS_HOST }}" OPENEDX_AWS_ACCESS_KEY: "" OPENEDX_AWS_SECRET_ACCESS_KEY: ""