Change nginx configuration based on BASE_URL, instead of moving actual files
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
BASE_URL=${BASE_URL:-/}
|
||||||
NGINX_ROOT=/usr/share/nginx/html
|
NGINX_ROOT=/usr/share/nginx/html
|
||||||
INDEX_FILE=$NGINX_ROOT/index.html
|
INDEX_FILE=$NGINX_ROOT/index.html
|
||||||
|
|
||||||
@@ -22,13 +23,7 @@ replace_or_delete_in_index () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [ "${BASE_URL}" ]; then
|
if [ "${BASE_URL}" ]; then
|
||||||
NGINX_WITH_BASE_URL="${NGINX_ROOT}${BASE_URL}"
|
sed -i "s|location .* {|location $BASE_URL {|g" /etc/nginx/nginx.conf
|
||||||
|
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
replace_in_index myApiKeyXXXX123456789 $API_KEY
|
replace_in_index myApiKeyXXXX123456789 $API_KEY
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ http {
|
|||||||
server {
|
server {
|
||||||
listen 8080;
|
listen 8080;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
index index.html index.htm;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
alias /usr/share/nginx/html/;
|
||||||
index index.html index.htm;
|
|
||||||
if ($request_method = 'OPTIONS') {
|
if ($request_method = 'OPTIONS') {
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
|||||||
Reference in New Issue
Block a user