Skip to content

Commit

Permalink
fix: verify minio host is defined on scorm proxy (#96)
Browse files Browse the repository at this point in the history
* fix: verify minio host is defined on scorm proxy

* chore: refactor scorm template

(cherry picked from commit 503ab92)
  • Loading branch information
Ian2012 committed Apr 26, 2024
1 parent eaa6c2c commit 466b01a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 40 deletions.
64 changes: 36 additions & 28 deletions drydock/patches/caddyfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
{% if DRYDOCK_ENABLE_MULTITENANCY -%}
{$default_site_port} {
@favicon_matcher {
path_regexp ^/favicon.ico$
}
rewrite @favicon_matcher /theming/asset/images/favicon.ico
@favicon_matcher {
path_regexp ^/favicon.ico$
}
rewrite @favicon_matcher /theming/asset/images/favicon.ico

{{ patch("caddyfile-mfe-by-path") }}
{{ patch("caddyfile-mfe-by-path") }}

# Limit profile image upload size
request_body /api/profile_images/*/*/upload {
max_size 1MB
}
request_body {
max_size 4MB
}
import proxy "lms:8000"
{% if DRYDOCK_ENABLE_SCORM and (MINIO_HOST is defined or S3_STORAGE_BUCKET is defined) -%}
@scorm_matcher {
path /scorm-proxy/*
}
route @scorm_matcher {
uri /scorm-proxy/* strip_prefix /scorm-proxy
{% if MINIO_HOST is defined %}
reverse_proxy minio:9000 {
header_up Host {{ MINIO_HOST }}
{% elif S3_STORAGE_BUCKET is defined %}
reverse_proxy https://{{ S3_STORAGE_BUCKET }}.s3.amazonaws.com {
header_up Host {{ S3_STORAGE_BUCKET }}.s3.amazonaws.com
{% endif %}
# Limit profile image upload size
request_body /api/profile_images/*/*/upload {
max_size 1MB
}
request_body {
max_size 4MB
}
import proxy "lms:8000"

{% if DRYDOCK_ENABLE_SCORM and MINIO_HOST is defined %}
@scorm_matcher {
path /scorm-proxy/*
}
route @scorm_matcher {
uri /scorm-proxy/* strip_prefix /scorm-proxy
reverse_proxy minio:9000 {
header_up Host {{ MINIO_HOST }}
}
}
{% elif DRYDOCK_ENABLE_SCORM and S3_STORAGE_BUCKET is defined %}
@scorm_matcher {
path /scorm-proxy/*
}
route @scorm_matcher {
uri /scorm-proxy/* strip_prefix /scorm-proxy
reverse_proxy https://{{ S3_STORAGE_BUCKET }}.s3.amazonaws.com {
header_up Host {{ S3_STORAGE_BUCKET }}.s3.amazonaws.com
}
}
{% endif %}

}
{% endif %}
}

{% endif %}
16 changes: 10 additions & 6 deletions drydock/patches/caddyfile-cms
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{% if DRYDOCK_ENABLE_SCORM and (MINIO_HOST is defined or S3_STORAGE_BUCKET is defined) -%}
{% if DRYDOCK_ENABLE_SCORM and MINIO_HOST is defined %}
@scorm_matcher {
path /scorm-proxy/*
}
route @scorm_matcher {
{% if MINIO_HOST is defined %}
uri replace /scorm-proxy/ /{{ MINIO_BUCKET_NAME }}/
reverse_proxy minio:9000 {
header_up Host {{ MINIO_HOST }}
{% elif S3_STORAGE_BUCKET is defined %}
header_up Host {{ MINIO_HOST }}
}
}
{% elif DRYDOCK_ENABLE_SCORM and S3_STORAGE_BUCKET is defined %}
@scorm_matcher {
path /scorm-proxy/*
}
route @scorm_matcher {
uri /scorm-proxy/* strip_prefix /scorm-proxy
reverse_proxy https://{{ S3_STORAGE_BUCKET }}.s3.amazonaws.com {
header_up Host {{ S3_STORAGE_BUCKET }}.s3.amazonaws.com
{% endif %}
header_up Host {{ S3_STORAGE_BUCKET }}.s3.amazonaws.com
}
}
{% endif %}
16 changes: 10 additions & 6 deletions drydock/patches/caddyfile-lms
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{% if DRYDOCK_ENABLE_SCORM and (MINIO_HOST is defined or S3_STORAGE_BUCKET is defined) -%}
{% if DRYDOCK_ENABLE_SCORM and MINIO_HOST is defined %}
@scorm_matcher {
path /scorm-proxy/*
}
route @scorm_matcher {
{% if MINIO_HOST is defined %}
uri replace /scorm-proxy/ /{{ MINIO_BUCKET_NAME }}/
reverse_proxy minio:9000 {
header_up Host {{ MINIO_HOST }}
{% elif S3_STORAGE_BUCKET is defined %}
header_up Host {{ MINIO_HOST }}
}
}
{% elif DRYDOCK_ENABLE_SCORM and S3_STORAGE_BUCKET is defined %}
@scorm_matcher {
path /scorm-proxy/*
}
route @scorm_matcher {
uri /scorm-proxy/* strip_prefix /scorm-proxy
reverse_proxy https://{{ S3_STORAGE_BUCKET }}.s3.amazonaws.com {
header_up Host {{ S3_STORAGE_BUCKET }}.s3.amazonaws.com
{% endif %}
header_up Host {{ S3_STORAGE_BUCKET }}.s3.amazonaws.com
}
}
{% endif %}

0 comments on commit 466b01a

Please sign in to comment.