Change nginx configuration based on BASE_URL, instead of moving actual files

This commit is contained in:
Jatesadakarn Saengrat
2018-01-05 18:56:30 +07:00
parent a9ea10da2c
commit 8e4f94b33f
2 changed files with 5 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
set -e
BASE_URL=${BASE_URL:-/}
NGINX_ROOT=/usr/share/nginx/html
INDEX_FILE=$NGINX_ROOT/index.html
@@ -22,13 +23,7 @@ replace_or_delete_in_index () {
}
if [ "${BASE_URL}" ]; then
NGINX_WITH_BASE_URL="${NGINX_ROOT}${BASE_URL}"
mkdir -p ${NGINX_WITH_BASE_URL}
mv ${NGINX_ROOT}/*.* ${NGINX_WITH_BASE_URL}/
INDEX_FILE=$NGINX_WITH_BASE_URL/index.html
NGINX_ROOT=$NGINX_WITH_BASE_URL
sed -i "s|location .* {|location $BASE_URL {|g" /etc/nginx/nginx.conf
fi
replace_in_index myApiKeyXXXX123456789 $API_KEY