Skip to content

Commit 1c183e8

Browse files
Revert "depr!: remove preview site configurations (#1238)" (#1243)
This reverts commit c780e0a. We revert this commit as the upstream change was merged in the master branch and is not to be backported to teak. Therefore, the current builds running on top of teak are failing.
1 parent 863a513 commit 1c183e8

File tree

10 files changed

+27
-2
lines changed

10 files changed

+27
-2
lines changed

docs/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ When ``ENABLE_HTTPS`` is ``true``, the whole Open edX platform will be reconfigu
292292
The following DNS records must exist and point to your server::
293293

294294
LMS_HOST (e.g: myopenedx.com)
295+
PREVIEW_LMS_HOST (e.g: preview.myopenedx.com)
295296
CMS_HOST (e.g: studio.myopenedx.com)
296297

297298
Thus, **this feature will (probably) not work in development** because the DNS records will (probably) not point to your development machine.

docs/tutorials/proxy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ With these changes, Tutor will no longer listen to ports 80 and 443 on the host.
2020

2121
It is then your responsibility to configure the web proxy on the host. There are too many use cases and proxy vendors, so Tutor does not provide configuration files that will work for everyone. You should configure your web proxy to:
2222

23-
- Capture traffic for the following hostnames: LMS_HOST, CMS_HOST, as well as any additional host exposed by your plugins (MFE_HOST, CREDENTIALS_HOST, etc.). See each plugin documentation for more information.
23+
- Capture traffic for the following hostnames: LMS_HOST, PREVIEW_LMS_HOST, CMS_HOST, as well as any additional host exposed by your plugins (MFE_HOST, CREDENTIALS_HOST, etc.). See each plugin documentation for more information.
2424
- If SSL/TLS is enabled:
2525
- Perform SSL/TLS termination using your own certificates.
2626
- Forward http traffic to https.

tutor/commands/jobs_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ def assign_theme(name, domain):
177177
"{{ LMS_HOST }}:8000",
178178
"{{ CMS_HOST }}",
179179
"{{ CMS_HOST }}:8001",
180+
"{{ PREVIEW_LMS_HOST }}",
181+
"{{ PREVIEW_LMS_HOST }}:8000",
180182
]
181183
for domain_name in domain_names:
182184
python_command += f"assign_theme('{theme_name}', '{domain_name}')\n"

tutor/config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,19 @@ def _update_enabled_plugins_on_unload(_plugin: str, _root: str, config: Config)
342342
Note that this action must be performed after the plugin has been unloaded, hence the low priority.
343343
"""
344344
save_enabled_plugins(config)
345+
346+
347+
@hooks.Actions.CONFIG_LOADED.add()
348+
def _check_preview_lms_host(config: Config) -> None:
349+
"""
350+
This will check if the PREVIEW_LMS_HOST is a subdomain of LMS_HOST.
351+
if not, prints a warning to notify the user.
352+
"""
353+
354+
lms_host = get_typed(config, "LMS_HOST", str, "")
355+
preview_lms_host = get_typed(config, "PREVIEW_LMS_HOST", str, "")
356+
if not preview_lms_host.endswith("." + lms_host):
357+
fmt.echo_alert(
358+
f'Warning: PREVIEW_LMS_HOST="{preview_lms_host}" is not a subdomain of LMS_HOST="{lms_host}". '
359+
"This configuration is not typically recommended and may lead to unexpected behavior."
360+
)

tutor/templates/apps/caddy/Caddyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{{ patch("caddyfile-proxy")|indent(4) }}
4242
}
4343

44-
{{ LMS_HOST }}{$default_site_port} {
44+
{{ LMS_HOST }}{$default_site_port}, {{ PREVIEW_LMS_HOST }}{$default_site_port} {
4545
@favicon_matcher {
4646
path_regexp ^/favicon.ico$
4747
}

tutor/templates/apps/openedx/config/cms.env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ FEATURES:
88
{{ patch("common-env-features")|indent(2) }}
99
{{ patch("cms-env-features")|indent(2) }}
1010
CERTIFICATES_HTML_VIEW: true
11+
PREVIEW_LMS_BASE: "{{ PREVIEW_LMS_HOST }}"
1112
ENABLE_CSMH_EXTENDED: false
1213
ENABLE_LEARNER_RECORDS: false
1314
ENABLE_LIBRARY_INDEX: true

tutor/templates/apps/openedx/config/lms.env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ FEATURES:
88
{{ patch("common-env-features")|indent(2) }}
99
{{ patch("lms-env-features")|indent(2) }}
1010
CERTIFICATES_HTML_VIEW: true
11+
PREVIEW_LMS_BASE: "{{ PREVIEW_LMS_HOST }}"
1112
ENABLE_CSMH_EXTENDED: false
1213
ENABLE_COMBINED_LOGIN_REGISTRATION: true
1314
ENABLE_GRADE_DOWNLOADS: true

tutor/templates/apps/openedx/settings/cms/development.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
SOCIAL_AUTH_EDX_OAUTH2_KEY = "{{ CMS_OAUTH2_KEY_SSO_DEV }}"
1717
SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = LMS_ROOT_URL
1818

19+
FEATURES["PREVIEW_LMS_BASE"] = "{{ PREVIEW_LMS_HOST }}:8000"
20+
1921
# Setup correct webpack configuration file for development
2022
WEBPACK_CONFIG_PATH = "webpack.dev.config.js"
2123

tutor/templates/apps/openedx/settings/lms/production.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
ALLOWED_HOSTS = [
88
ENV_TOKENS.get("LMS_BASE"),
9+
FEATURES["PREVIEW_LMS_BASE"],
910
"lms",
1011
]
1112
CORS_ORIGIN_WHITELIST.append("{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}")

tutor/templates/config/defaults.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ MYSQL_PORT: 3306
6868
MYSQL_ROOT_USERNAME: "root"
6969
NPM_REGISTRY: "https://registry.npmjs.org/"
7070
PLATFORM_NAME: "My Open edX"
71+
PREVIEW_LMS_HOST: "preview.{{ LMS_HOST }}"
7172
REDIS_HOST: "redis"
7273
REDIS_PORT: 6379
7374
REDIS_USERNAME: ""

0 commit comments

Comments
 (0)