From 97d43c78d398b1c404a1d7a22e6c8f9d27519428 Mon Sep 17 00:00:00 2001 From: Michael Hollister Date: Mon, 11 Mar 2024 23:58:55 -0500 Subject: [PATCH 1/2] Added MMR media redirect config options --- .../matrix-media-repo/defaults/main.yml | 15 ++++++++++++++ .../templates/media-repo/media-repo.yaml.j2 | 20 ++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/roles/custom/matrix-media-repo/defaults/main.yml b/roles/custom/matrix-media-repo/defaults/main.yml index bab6155bb..63a225674 100755 --- a/roles/custom/matrix-media-repo/defaults/main.yml +++ b/roles/custom/matrix-media-repo/defaults/main.yml @@ -386,6 +386,21 @@ matrix_media_repo_datastore_s3_opts_bucket_name: "your-media-bucket" # See https://aws.amazon.com/s3/storage-classes/ for details; uncomment to use. # matrix_media_repo_datastore_s3_opts_storage_class: "STANDARD" +# When set, if the requesting user/server supports being redirected, and MMR is capable +# of performing that redirection, they will be redirected to the given object location. +# The object ID used in S3 is assumed to be the file name, and will simply be appended. +# It is therefore important to include any trailing slashes or path information. For +# example, an object with ID "hello/world" will get converted to "https://mycdn.example.org/hello/world". +# Note that MMR may not redirect in all cases, even if the client/server requests the +# capability. MMR may still be responsible for bandwidth charges incurred from going to +# the bucket directly. +# matrix_media_repo_datastore_s3_opts_public_base_url: "https://mycdn.example.org/" + +# Set to `true` to bypass any local cache when `publicBaseUrl` is set. Has no effect +# when `publicBaseUrl` is unset. Defaults to false (cached media will be served by MMR +# before redirection if present). +matrix_media_repo_datastore_s3_opts_redirect_when_cached: true + # Options for controlling archives. Archives are exports of a particular user's content for # the purpose of GDPR or moving media to a different server. diff --git a/roles/custom/matrix-media-repo/templates/media-repo/media-repo.yaml.j2 b/roles/custom/matrix-media-repo/templates/media-repo/media-repo.yaml.j2 index 8dec40b18..d0543ebe6 100644 --- a/roles/custom/matrix-media-repo/templates/media-repo/media-repo.yaml.j2 +++ b/roles/custom/matrix-media-repo/templates/media-repo/media-repo.yaml.j2 @@ -229,13 +229,23 @@ datastores: # some providers will need this (like Scaleway). Uncomment to use. #region: "sfo2" {% endif %} -{% if matrix_media_repo_datastore_s3_opts_storage_class is defined %} - storageClass: {{ matrix_media_repo_datastore_s3_opts_storage_class | to_json }} +{% if matrix_media_repo_datastore_s3_opts_public_base_url is defined %} + publicBaseUrl: {{ matrix_media_repo_datastore_s3_opts_public_base_url | to_json }} {% else %} - # An optional storage class for tuning how the media is stored at s3. - # See https://aws.amazon.com/s3/storage-classes/ for details; uncomment to use. - #storageClass: STANDARD + # When set, if the requesting user/server supports being redirected, and MMR is capable + # of performing that redirection, they will be redirected to the given object location. + # The object ID used in S3 is assumed to be the file name, and will simply be appended. + # It is therefore important to include any trailing slashes or path information. For + # example, an object with ID "hello/world" will get converted to "https://mycdn.example.org/hello/world". + # Note that MMR may not redirect in all cases, even if the client/server requests the + # capability. MMR may still be responsible for bandwidth charges incurred from going to + # the bucket directly. + #publicBaseUrl: "https://mycdn.example.org/" {% endif %} + # Set to `true` to bypass any local cache when `publicBaseUrl` is set. Has no effect + # when `publicBaseUrl` is unset. Defaults to false (cached media will be served by MMR + # before redirection if present). + redirectWhenCached: {{ matrix_media_repo_datastore_s3_opts_redirect_when_cached | to_json }} {% endif %} # Options for controlling archives. Archives are exports of a particular user's content for From 227541d407681f7ffd4c84ebf66ad63dcffd8022 Mon Sep 17 00:00:00 2001 From: Michael Hollister Date: Tue, 12 Mar 2024 00:03:59 -0500 Subject: [PATCH 2/2] Added back storageClass config option --- .../templates/media-repo/media-repo.yaml.j2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/roles/custom/matrix-media-repo/templates/media-repo/media-repo.yaml.j2 b/roles/custom/matrix-media-repo/templates/media-repo/media-repo.yaml.j2 index d0543ebe6..ee7d151b6 100644 --- a/roles/custom/matrix-media-repo/templates/media-repo/media-repo.yaml.j2 +++ b/roles/custom/matrix-media-repo/templates/media-repo/media-repo.yaml.j2 @@ -229,6 +229,13 @@ datastores: # some providers will need this (like Scaleway). Uncomment to use. #region: "sfo2" {% endif %} +{% if matrix_media_repo_datastore_s3_opts_storage_class is defined %} + storageClass: {{ matrix_media_repo_datastore_s3_opts_storage_class | to_json }} +{% else %} + # An optional storage class for tuning how the media is stored at s3. + # See https://aws.amazon.com/s3/storage-classes/ for details; uncomment to use. + #storageClass: STANDARD +{% endif %} {% if matrix_media_repo_datastore_s3_opts_public_base_url is defined %} publicBaseUrl: {{ matrix_media_repo_datastore_s3_opts_public_base_url | to_json }} {% else %}