From 2432a3a6609de8f80fe31bc8ba1ee898cfc5ef55 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 28 Aug 2023 15:01:54 -0400 Subject: [PATCH] feat: add minio support --- conf/nginx.conf.tpl | 24 ++++++++++++++++++++++++ conf/proxy_minio.conf | 6 ++++++ entrypoint.bash | 8 ++++++++ 3 files changed, 38 insertions(+) create mode 100644 conf/proxy_minio.conf diff --git a/conf/nginx.conf.tpl b/conf/nginx.conf.tpl index c79adbd..123bfa6 100644 --- a/conf/nginx.conf.tpl +++ b/conf/nginx.conf.tpl @@ -138,6 +138,30 @@ http { } # tpl__use_bento_public__end + # -- Fallback 404 to avoid returning web HTML when an API request is made + location /api/ { + return 404; + } + + # tpl__use_minio__start + # -- Minio + location /api/minio { return 302 https://${BENTOV2_DOMAIN}/api/minio/; } + location /api/minio/ { + # Reverse proxy settings + include /gateway/conf/proxy.conf; + include /gateway/conf/proxy_minio.conf; + + # Pass rewritten request to Minio + rewrite ^ $request_uri; + rewrite ^/api/minio/(.*) /$1 break; + return 400; + proxy_pass http://${BENTO_MINIO_CONTAINER_NAME}:${BENTO_MINIO_INTERNAL_PORT}$uri; + + # Log errors + error_log /var/log/bento_minio_errors.log; + } + # tpl__use_minio__end + # Include all public service location blocks (mounted into the container) include bento_public_services/*.conf; diff --git a/conf/proxy_minio.conf b/conf/proxy_minio.conf new file mode 100644 index 0000000..0b97e94 --- /dev/null +++ b/conf/proxy_minio.conf @@ -0,0 +1,6 @@ +client_body_timeout 660s; +proxy_read_timeout 660s; +proxy_send_timeout 660s; +send_timeout 660s; + +client_max_body_size 4000m; diff --git a/entrypoint.bash b/entrypoint.bash index 41c218f..81d2185 100644 --- a/entrypoint.bash +++ b/entrypoint.bash @@ -82,6 +82,14 @@ else '/tpl__use_bento_public__start/,/tpl__use_bento_public__end/d' \ ./nginx.conf.pre fi +if [[ "$(true_values_to_1 $BENTO_MINIO_ENABLED)" == 1 ]]; then + echo "[bento_gateway] [entrypoint] Fine-tuning nginx.conf to use Minio" +else + echo "[bento_gateway] [entrypoint] Fine-tuning nginx.conf to disable Minio" + sed -i.bak \ + '/tpl__use_minio__start/,/tpl__use_minio__end/d' \ + ./nginx.conf.pre +fi if [[ "$(true_values_to_1 $BENTO_CBIOPORTAL_ENABLED)" == 1 ]]; then echo "[bento_gateway] [entrypoint] Fine-tuning nginx.conf to use cBioPortal" else