Allow ClearML to be served with a URL path prefix (#121)

* add server root url

* [Feature Request] Add proxy_pass for root url other than /

* [Feature Request] Add proxy_pass for root url other than /

* add support for web sub path

* add support for web sub path

* use default conf instead of created a custom one

* code reivew: move cp command in if block

* Add commented env var in the docker-compose file

Co-authored-by: Zied ANDOLSI <zandolsi@prophesee.ai>
This commit is contained in:
Zied ANDOLSI 2022-03-22 16:21:58 +01:00 committed by GitHub
parent 5c1e419eb5
commit d92dfbbdb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 1 deletions

View File

@ -20,6 +20,7 @@ COPY --from=staging_image /opt/clearml/ /opt/clearml/
COPY --chmod=744 docker/build/internal_files/final_image_preparation.sh /tmp/internal_files/
COPY docker/build/internal_files/clearml.conf.template /tmp/internal_files/
COPY docker/build/internal_files/clearml_subpath.conf.template /tmp/internal_files/
RUN /bin/bash -c '/tmp/internal_files/final_image_preparation.sh'
COPY --from=webapp /opt/open-webapp/build /usr/share/nginx/html

View File

@ -41,6 +41,7 @@ http {
server_name _;
root /usr/share/nginx/html;
proxy_http_version 1.1;
client_max_body_size 0;
# comppression
gzip on;

View File

@ -0,0 +1,21 @@
location /${CLEARML_SERVER_SUB_PATH} {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:80;
rewrite /${CLEARML_SERVER_SUB_PATH}/(.*) /$1 break;
}
location /${CLEARML_SERVER_SUB_PATH}/api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:80/api;
rewrite /${CLEARML_SERVER_SUB_PATH}/api/(.*) /api/$1 break;
}
location /${CLEARML_SERVER_SUB_PATH}/files {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:80/files;
rewrite /${CLEARML_SERVER_SUB_PATH}/files/(.*) /files/$1 break;
rewrite /${CLEARML_SERVER_SUB_PATH}/files /files/ break;
}

View File

@ -48,9 +48,16 @@ EOF
export NGINX_APISERVER_ADDR=${NGINX_APISERVER_ADDRESS:-http://apiserver:8008}
export NGINX_FILESERVER_ADDR=${NGINX_FILESERVER_ADDRESS:-http://fileserver:8081}
envsubst '${NGINX_APISERVER_ADDR} ${NGINX_FILESERVER_ADDR}' < /etc/nginx/clearml.conf.template > /etc/nginx/nginx.conf
if [[ -n "${CLEARML_SERVER_SUB_PATH}" ]]; then
envsubst '${CLEARML_SERVER_SUB_PATH}' < /etc/nginx/clearml_subpath.conf.template > /etc/nginx/default.d/clearml_subpath.conf
cp /usr/share/nginx/html/env.js /usr/share/nginx/html/env.js.origin
envsubst '${CLEARML_SERVER_SUB_PATH}' < /usr/share/nginx/html/env.js.origin > /usr/share/nginx/html/env.js
cp /usr/share/nginx/html/index.html /usr/share/nginx/html/index.html.origin
sed 's/href="\/"/href="\/'${CLEARML_SERVER_SUB_PATH}'\/"/' /usr/share/nginx/html/index.html.origin > /usr/share/nginx/html/index.html
fi
#start the server
/usr/sbin/nginx -g "daemon off;"

View File

@ -15,4 +15,5 @@ ln -s /dev/stdout /var/log/nginx/access.log
ln -s /dev/stderr /var/log/nginx/error.log
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
mv /tmp/internal_files/clearml.conf.template /etc/nginx/clearml.conf.template
mv /tmp/internal_files/clearml_subpath.conf.template /etc/nginx/clearml_subpath.conf.template
yum clean all

View File

@ -108,6 +108,8 @@ services:
command:
- webserver
container_name: clearml-webserver
# environment:
# CLEARML_SERVER_SUB_PATH : clearml-web # Allow Clearml to be served with a URL path prefix.
image: allegroai/clearml:latest
restart: unless-stopped
depends_on: