Skip to content

Commit 839a138

Browse files
authored
Merge pull request #2256 from codalab/multiple_domains
Support for Multiple Domain names (instance behind reverse proxy)
2 parents 90c57c9 + d87143a commit 839a138

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

documentation/docs/Developers_and_Administrators/How-to-deploy-Codabench-on-your-server.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,4 +439,7 @@ Caddyfile :
439439
path /{$AWS_STORAGE_BUCKET_NAME}* /{$AWS_STORAGE_PRIVATE_BUCKET_NAME}*
440440
}
441441
reverse_proxy @min_bucket minio:{$MINIO_PORT}
442-
```
442+
```
443+
444+
## Codabench Instance behind a reverse proxy
445+
If you put your instance behind a reverse proxy and want that proxy to contact the instance via http or https, your `DOMAIN_NAME` might not be reachable from the outside. In this case, you can set `DOMAIN_NAME` as your internal domain name, used by the reverse proxy, and `EXTERNAL_DOMAIN_NAME` as the domain name that is known on external networks (like the internet).

src/settings/base.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@
1919
csrf_https_domain = "https://" + os.environ.get("DOMAIN_NAME").split(':')[0]
2020
csrf_http_domain = "http://" + os.environ.get("DOMAIN_NAME").split(':')[0]
2121

22-
CSRF_TRUSTED_ORIGINS = [csrf_https_domain, csrf_http_domain]
23-
CSRF_ALLOWED_ORIGINS = [csrf_https_domain, csrf_http_domain]
22+
if os.environ.get("EXTERNAL_DOMAIN_NAME", "") != "":
23+
csrf_https_external_domain = "https://" + os.environ.get("EXTERNAL_DOMAIN_NAME", "").split(':')[0]
24+
csrf_http_external_domain = "http://" + os.environ.get("EXTERNAL_DOMAIN_NAME", "").split(':')[0]
25+
CSRF_TRUSTED_ORIGINS = [csrf_https_domain, csrf_http_domain, csrf_https_external_domain, csrf_http_external_domain]
26+
CSRF_ALLOWED_ORIGINS = [csrf_https_domain, csrf_http_domain, csrf_https_external_domain, csrf_http_external_domain]
2427

25-
SITE_ID = 1
28+
DOMAIN_NAME = os.environ.get('EXTERNAL_DOMAIN_NAME').split(':')[0]
29+
else:
30+
CSRF_TRUSTED_ORIGINS = [csrf_https_domain, csrf_http_domain]
31+
CSRF_ALLOWED_ORIGINS = [csrf_https_domain, csrf_http_domain]
2632

27-
SITE_DOMAIN = os.environ.get('SITE_DOMAIN', 'http://localhost')
28-
DOMAIN_NAME = os.environ.get('DOMAIN_NAME', 'localhost').split(':')[0]
33+
DOMAIN_NAME = os.environ.get('DOMAIN_NAME', 'localhost').split(':')[0]
2934

30-
SELENIUM_HOSTNAME = os.environ.get("SELENIUM_HOSTNAME", "localhost")
35+
SITE_DOMAIN = os.environ.get('SITE_DOMAIN', 'http://localhost')
36+
SITE_ID = 1
3137

3238

3339
THIRD_PARTY_APPS = (

0 commit comments

Comments
 (0)