From 2b94c3e24cf5c96a223d223be5ae23d9f1813d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20R=C3=B6hrich?= Date: Mon, 6 Nov 2023 16:04:47 +0100 Subject: [PATCH] object store: proxy object store UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Proxy object store UI in the nginx of the Longhorn UI. This allows for port-forwarding of the Longhorn UI to also access the administrative interface of the s3gw UI instances Signed-off-by: Moritz Röhrich --- Dockerfile | 8 +++++--- entrypoint.sh | 13 +++++++++++++ nginx.conf.template | 11 +++++++++++ src/routes/objectStorage/index.js | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 098bf7a2c..85275f75b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN npm run build FROM registry.suse.com/bci/bci-base:15.4 RUN zypper -n ref && \ - zypper -n install curl libxml2 bash gettext shadow nginx + zypper -n install curl libxml2 bash gettext shadow nginx awk SHELL [ "/bin/bash", "-o", "pipefail", "-c" ] @@ -21,11 +21,13 @@ RUN mkdir -p web/dist WORKDIR /web COPY --from=builder /web/dist /web/dist -COPY --from=builder /web/nginx.conf.template /etc/nginx/nginx.conf.template +COPY nginx.conf.template /etc/nginx/nginx.conf.template +COPY entrypoint.sh /entrypoint.sh EXPOSE 8000 ENV LONGHORN_MANAGER_IP http://localhost:9500 ENV LONGHORN_UI_PORT 8000 +ENV LONGHORN_NAMESPACE longhorn-system RUN mkdir -p /var/config/nginx/ \ && cp -r /etc/nginx/* /var/config/nginx/ \ @@ -35,4 +37,4 @@ RUN mkdir -p /var/config/nginx/ \ # Use the uid of the default user (nginx) from the installed nginx package USER 499 -CMD ["/bin/bash", "-c", "envsubst '${LONGHORN_MANAGER_IP},${LONGHORN_UI_PORT}' < /etc/nginx/nginx.conf.template > /var/config/nginx/nginx.conf && nginx -c /var/config/nginx/nginx.conf -g 'daemon off;'"] +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 000000000..2cf07a411 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +NAMESERVER_IP="$(grep -E '^nameserver' /etc/resolv.conf | head -n 1 | awk '{print $2}')" +LONGHORN_NAMESPACE_DOMAIN="$(grep -E '^search' /etc/resolv.conf | head -n 1 | awk '{print $2}')" + +export NAMESERVER_IP +export LONGHORN_NAMESPACE_DOMAIN + +envsubst '${LONGHORN_MANAGER_IP},${LONGHORN_UI_PORT},${LONGHORN_NAMESPACE_DOMAIN},${NAMESERVER_IP}' \ + < /etc/nginx/nginx.conf.template \ + > /var/config/nginx/nginx.conf + +nginx -c /var/config/nginx/nginx.conf diff --git a/nginx.conf.template b/nginx.conf.template index cb45f62b1..ba6f938dc 100644 --- a/nginx.conf.template +++ b/nginx.conf.template @@ -1,5 +1,11 @@ events { worker_connections 1024; } +daemon off; + +error_log /dev/stdout info; + http { + access_log /dev/stdout; + server { gzip on; gzip_min_length 1k; @@ -38,6 +44,11 @@ http { root /web/dist; } + location ~ ^/objectstore/([^/]+) { + resolver ${NAMESERVER_IP}; + proxy_pass http://$1.${LONGHORN_NAMESPACE_DOMAIN}:8080; + } + location / { root /web/dist; index index.html; diff --git a/src/routes/objectStorage/index.js b/src/routes/objectStorage/index.js index b1535e8eb..b9acded6c 100644 --- a/src/routes/objectStorage/index.js +++ b/src/routes/objectStorage/index.js @@ -183,7 +183,7 @@ class ObjectStore extends React.Component { }, administrateObjectStore: (record) => { if (record.name?.length) { - window.open(record.name, '_blank', 'noreferrer') + window.open(`objectstore/${record.name}/`, '_blank', 'noreferrer') } }, deleteObjectStore: (record) => {