Skip to content

Commit

Permalink
Merge pull request #21 from bento-platform/feat/minio
Browse files Browse the repository at this point in the history
feat: minio proxy config
  • Loading branch information
v-rocheleau authored Dec 20, 2024
2 parents 2115482 + 334282b commit 4ef73ac
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
68 changes: 68 additions & 0 deletions conf/minio.conf.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
server {
# tpl__tls_yes__start
listen 444 ssl;
# tpl__tls_yes__end
# tpl__tls_no__start
listen 80;
# tpl__tls_no__end
server_name ${BENTO_MINIO_DOMAIN};

# tpl__tls_yes__start
ssl_certificate ${BENTOV2_GATEWAY_INTERNAL_CERTS_DIR}${BENTO_GATEWAY_INTERNAL_MINIO_FULLCHAIN_RELATIVE_PATH};
ssl_certificate_key ${BENTOV2_GATEWAY_INTERNAL_CERTS_DIR}${BENTO_GATEWAY_INTERNAL_MINIO_PRIVKEY_RELATIVE_PATH};
# tpl__tls_yes__end

# Allow special characters in headers
ignore_invalid_headers off;

# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;

# Disable buffering
proxy_buffering off;
proxy_request_buffering off;

location / {
# Reverse proxy settings
include /gateway/conf/proxy.conf;
include /gateway/conf/proxy_extra.conf;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://${BENTO_MINIO_CONTAINER_NAME}:${BENTO_MINIO_INTERNAL_PORT};

# Errors
error_log /var/log/bentov2_minio_errors.log;
}

location /minio/ui { return 302 https://${BENTO_MINIO_DOMAIN}/minio/ui/; }
location /minio/ui/ {
# General reverse proxy settings
include /gateway/conf/proxy.conf;
include /gateway/conf/proxy_extra.conf;
# This is necessary to pass the correct IP to be hashed
proxy_set_header X-NginX-Proxy true;
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
# Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)
# Uncomment the following line to set the Origin request to an empty string
proxy_set_header Origin '';
chunked_transfer_encoding off;
rewrite ^ $request_uri;
rewrite ^/minio/ui/(.*) /$1 break;
proxy_pass http://${BENTO_MINIO_CONTAINER_NAME}:${BENTO_MINIO_CONSOLE_PORT}$uri;

# Errors
error_log /var/log/bentov2_minio_errors.log;
}
}
4 changes: 4 additions & 0 deletions conf/nginx.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,8 @@ http {
}
# tpl__redirect_yes__end

# tpl__use_minio__start
include minio.conf;
# tpl__use_minio__end

}
29 changes: 29 additions & 0 deletions entrypoint.bash
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ envsubst "$(cat ./VARIABLES)" \
< ./conf/nginx.conf.tpl \
> ./nginx.conf.pre

echo "[bento_gateway] [entrypoint] creating minio.conf.pre"
envsubst "$(cat ./VARIABLES)" \
< ./conf/minio.conf.tpl \
> ./minio.conf.pre

# ----------------------------------------------------------------------------------------------------------------------

# Run "fine-tuning", i.e., processing the configuration files to *remove* chunks that aren't relevant to the environment
Expand All @@ -92,6 +97,19 @@ else
./cbioportal.conf.pre
fi

# Run fine-tuning on minio.conf.pre
if [[ "${use_tls}" == 0 ]]; then
echo "[bento_gateway] [entrypoint] Fine-tuning minio.conf to not use TLS"
sed -i.bak \
'/tpl__tls_yes__start/,/tpl__tls_yes__end/d' \
./minio.conf.pre
else
echo "[bento_gateway] [entrypoint] Fine-tuning minio.conf to use TLS"
sed -i.bak \
'/tpl__tls_no__start/,/tpl__tls_no__end/d' \
./minio.conf.pre
fi

# Run fine-tuning on nginx.conf.pre
if [[ "${use_tls}" == 0 ]]; then
echo "[bento_gateway] [entrypoint] Fine-tuning nginx.conf to not use TLS"
Expand Down Expand Up @@ -139,11 +157,22 @@ else
'/tpl__redirect_yes__start/,/tpl__redirect_yes__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

# ----------------------------------------------------------------------------------------------------------------------

# Generate final configuration files / locations -----------------------------------------------------------------------
# - Move cbioportal.conf into position
cp ./cbioportal.conf.pre "${BENTO_GATEWAY_CONF_DIR}/cbioportal.conf"
# - Move minio.conf into position
cp ./minio.conf.pre "${BENTO_GATEWAY_CONF_DIR}/minio.conf"
# - Move nginx.conf into position
cp ./nginx.conf.pre "${BENTO_GATEWAY_CONF_DIR}/nginx.conf"
# - Remove pre-final configuration files + any backups
Expand Down

0 comments on commit 4ef73ac

Please sign in to comment.