fix: Allow local ref's to be served by nginx (#5565)
This commit is contained in:
@@ -34,6 +34,7 @@ http {
|
|||||||
expires 1d;
|
expires 1d;
|
||||||
|
|
||||||
location ~* \.(?:json|yml|yaml)$ {
|
location ~* \.(?:json|yml|yaml)$ {
|
||||||
|
#SWAGGER_ROOT
|
||||||
expires -1;
|
expires -1;
|
||||||
|
|
||||||
include cors.conf;
|
include cors.conf;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ set -e
|
|||||||
BASE_URL=${BASE_URL:-/}
|
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
|
||||||
|
NGINX_CONF=/etc/nginx/nginx.conf
|
||||||
|
|
||||||
node /usr/share/nginx/configurator $INDEX_FILE
|
node /usr/share/nginx/configurator $INDEX_FILE
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ replace_or_delete_in_index () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [ "${BASE_URL}" ]; then
|
if [ "${BASE_URL}" ]; then
|
||||||
sed -i "s|location / {|location $BASE_URL {|g" /etc/nginx/nginx.conf
|
sed -i "s|location / {|location $BASE_URL {|g" $NGINX_CONF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
replace_in_index myApiKeyXXXX123456789 $API_KEY
|
replace_in_index myApiKeyXXXX123456789 $API_KEY
|
||||||
@@ -37,13 +38,20 @@ fi
|
|||||||
if [[ -f "$SWAGGER_JSON" ]]; then
|
if [[ -f "$SWAGGER_JSON" ]]; then
|
||||||
cp -s "$SWAGGER_JSON" "$NGINX_ROOT"
|
cp -s "$SWAGGER_JSON" "$NGINX_ROOT"
|
||||||
REL_PATH="./$(basename $SWAGGER_JSON)"
|
REL_PATH="./$(basename $SWAGGER_JSON)"
|
||||||
|
|
||||||
|
if [[ -z "$SWAGGER_ROOT" ]]; then
|
||||||
|
SWAGGER_ROOT="$(dirname $SWAGGER_JSON)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i "s|#SWAGGER_ROOT|root $SWAGGER_ROOT;|g" $NGINX_CONF
|
||||||
|
|
||||||
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
|
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
|
||||||
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
|
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# replace the PORT that nginx listens on if PORT is supplied
|
# replace the PORT that nginx listens on if PORT is supplied
|
||||||
if [[ -n "${PORT}" ]]; then
|
if [[ -n "${PORT}" ]]; then
|
||||||
sed -i "s|8080|${PORT}|g" /etc/nginx/nginx.conf
|
sed -i "s|8080|${PORT}|g" $NGINX_CONF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $NGINX_ROOT -type f -regex ".*\.\(html\|js\|css\)" -exec sh -c "gzip < {} > {}.gz" \;
|
find $NGINX_ROOT -type f -regex ".*\.\(html\|js\|css\)" -exec sh -c "gzip < {} > {}.gz" \;
|
||||||
|
|||||||
Reference in New Issue
Block a user