-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Is this a bug or feature request?
Bug
What is the current behavior?
When using a (nginx) reverse proxy and passing WEBAPI_URL=https://metasfresh.domain.tld through docker-compose.yml,
start_webui.sh replaces https to http and thus provokes a mixed content issue.
File in question:
https://github.com/metasfresh/metasfresh-docker/blob/master/docker-src/webui/sources/start_webui.sh
after else, line sed -i 's/\https\b/http/g' /opt/metasfresh-webui-frontend/dist/config.js
#!/bin/bash
if [[ ! -z $WEBAPI_URL ]]; then
sed -i 's,http\:\/\/MYDOCKERHOST\:PORT,'$WEBAPI_URL',g' /opt/metasfresh-webui-frontend/dist/config.js
fi
if [[ -f "/etc/apache2/certs/fullchain.pem" ]] && [[ -f "/etc/apache2/certs/privkey.pem" ]]; then
sed -i 's/\bhttp\b/https/g' /opt/metasfresh-webui-frontend/dist/config.js
a2ensite metasfresh_webui_ssl.conf
echo "[METASFRESH] Activated SSL!"
else
sed -i 's/\https\b/http/g' /opt/metasfresh-webui-frontend/dist/config.js
a2ensite metasfresh_webui.conf
a2dissite metasfresh_webui_ssl.conf
echo "[METASFRESH] Runnning Non-SSL!"
fi
Which are the steps to reproduce?
Run metasfresh docker using the example docker-compose file without certificates and then reverse proxy it.
What is the expected or desired behavior?
Assume that the input in WEBAPI_URL is correct including the protocol and write it as is into the config.js file.
Alternative: Provide an option for reverse proxy.
Hotfix
bash into your container
docker exec -it metasfresh_docker_webui_1 /bin/bash
install editor nano, vi..
apt-get install nano
edit files
nano start_webui.sh
comment out the line like so #sed -i 's/\https\b/http/g' /opt/metasfresh-webui-frontend/dist/config.js or remove it
ctrl / strg+x, y to exit nano
nano /opt/metasfresh-webui-frontend/dist/config.js
replace http with https again
API_URL: 'https://metasfresh.domain.tld/rest/api',
WS_URL: 'https://metasfresh.domain.tld/stomp'
(you can also add the ports if you have a different one like https://metasfresh.domain.tld:8443)
ctrl / strg+x, y to exit nano
you dont need to restart anything, because the config is read as the site is accessed. Changing the start script start_webui.sh makes sure it stays that way even after restarting.
Hotfix 2
I created a start_webui.sh in the sources folder path/metasfresh-docker/webui/sources/
with the line #sed -i 's/\https\b/http/g' /opt/metasfresh-webui-frontend/dist/config.js
and changed the Dockerfile in path/metasfresh-docker/webui/ as follows:
after
COPY sources/configs/config.js /opt/metasfresh-webui-frontend/dist/
add 2 lines:
COPY sources/start_webui.sh /
RUN ["chmod", "+x", "start_webui.sh"]