From 929b06d6878496f70fb7f7784181ce0c1f7b0967 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 2 Mar 2022 18:51:35 +0100 Subject: [PATCH 1/2] Only pass 40-char persistent resource matches to GCS --- root-files/opt/flownative/lib/nginx-legacy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/root-files/opt/flownative/lib/nginx-legacy.sh b/root-files/opt/flownative/lib/nginx-legacy.sh index 8fde553..2d666fc 100644 --- a/root-files/opt/flownative/lib/nginx-legacy.sh +++ b/root-files/opt/flownative/lib/nginx-legacy.sh @@ -174,7 +174,8 @@ EOM if [ -n "${BEACH_GOOGLE_CLOUD_STORAGE_PUBLIC_BUCKET}" ]; then cat >>"${NGINX_CONF_PATH}/sites-enabled/site.conf" <<-EOM - location ~* ^${BEACH_PERSISTENT_RESOURCES_BASE_PATH}([a-f0-9]+)/ { + # pass persistent resource requests to GCS + location ~* "^${BEACH_PERSISTENT_RESOURCES_BASE_PATH}([a-f0-9]{40})/" { resolver 8.8.8.8; expires 3600; proxy_set_header Authorization ""; From 76fe957280681231791b7c8da5e374308b9e4eea Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 2 Mar 2022 18:52:18 +0100 Subject: [PATCH 2/2] Redirect "subdivided" persistent resource requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … to remove the subdivision parts --- root-files/opt/flownative/lib/nginx-legacy.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/root-files/opt/flownative/lib/nginx-legacy.sh b/root-files/opt/flownative/lib/nginx-legacy.sh index 2d666fc..ce1041a 100644 --- a/root-files/opt/flownative/lib/nginx-legacy.sh +++ b/root-files/opt/flownative/lib/nginx-legacy.sh @@ -174,6 +174,11 @@ EOM if [ -n "${BEACH_GOOGLE_CLOUD_STORAGE_PUBLIC_BUCKET}" ]; then cat >>"${NGINX_CONF_PATH}/sites-enabled/site.conf" <<-EOM + # redirect "subdivided" persistent resource requests to remove the subdivision parts + # e.g. _Resources/Persistent/1/2/3/4/123456789… to _Resources/Persistent/123456789… + location ~* "^${BEACH_PERSISTENT_RESOURCES_BASE_PATH}(?:[0-9a-f]/){4}([0-9a-f]{40}/.*)" { + return 301 \$scheme://\$host${BEACH_PERSISTENT_RESOURCES_BASE_PATH}\$1; + } # pass persistent resource requests to GCS location ~* "^${BEACH_PERSISTENT_RESOURCES_BASE_PATH}([a-f0-9]{40})/" { resolver 8.8.8.8;