Skip to content

Commit f353974

Browse files
authoredJun 10, 2020
fix: Allow local ref's to be served by nginx (#5565)
1 parent 5217366 commit f353974

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎docker/nginx.conf

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ http {
3434
expires 1d;
3535

3636
location ~* \.(?:json|yml|yaml)$ {
37+
#SWAGGER_ROOT
3738
expires -1;
3839

3940
include cors.conf;

‎docker/run.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44
BASE_URL=${BASE_URL:-/}
55
NGINX_ROOT=/usr/share/nginx/html
66
INDEX_FILE=$NGINX_ROOT/index.html
7+
NGINX_CONF=/etc/nginx/nginx.conf
78

89
node /usr/share/nginx/configurator $INDEX_FILE
910

@@ -24,7 +25,7 @@ replace_or_delete_in_index () {
2425
}
2526

2627
if [ "${BASE_URL}" ]; then
27-
sed -i "s|location / {|location $BASE_URL {|g" /etc/nginx/nginx.conf
28+
sed -i "s|location / {|location $BASE_URL {|g" $NGINX_CONF
2829
fi
2930

3031
replace_in_index myApiKeyXXXX123456789 $API_KEY
@@ -37,13 +38,20 @@ fi
3738
if [[ -f "$SWAGGER_JSON" ]]; then
3839
cp -s "$SWAGGER_JSON" "$NGINX_ROOT"
3940
REL_PATH="./$(basename $SWAGGER_JSON)"
41+
42+
if [[ -z "$SWAGGER_ROOT" ]]; then
43+
SWAGGER_ROOT="$(dirname $SWAGGER_JSON)"
44+
fi
45+
46+
sed -i "s|#SWAGGER_ROOT|root $SWAGGER_ROOT;|g" $NGINX_CONF
Has a conversation. Original line has a conversation.
47+
4048
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
4149
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
4250
fi
4351

4452
# replace the PORT that nginx listens on if PORT is supplied
4553
if [[ -n "${PORT}" ]]; then
46-
sed -i "s|8080|${PORT}|g" /etc/nginx/nginx.conf
54+
sed -i "s|8080|${PORT}|g" $NGINX_CONF
4755
fi
4856

4957
find $NGINX_ROOT -type f -regex ".*\.\(html\|js\|css\)" -exec sh -c "gzip < {} > {}.gz" \;

0 commit comments

Comments
 (0)
Please sign in to comment.