diff --git a/dockerfiles/nginx/entrypoint.sh b/dockerfiles/nginx/entrypoint.sh index 42af4fc..aed2cde 100644 --- a/dockerfiles/nginx/entrypoint.sh +++ b/dockerfiles/nginx/entrypoint.sh @@ -1,3 +1,9 @@ #!/bin/sh -envsubst "\$BACKEND_PORT \$FRONTEND_PORT" < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf + +# Set default values +: "${SWAGGER_PATH:=swagger}" +: "${BACKEND_PORT:=5000}" +: "${FRONTEND_PORT:=3000}" + +envsubst "\$BACKEND_PORT \$FRONTEND_PORT \$SWAGGER_PATH" < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf nginx -g 'daemon off;' diff --git a/dockerfiles/nginx/nginx.conf b/dockerfiles/nginx/nginx.conf index d9c80de..5179697 100644 --- a/dockerfiles/nginx/nginx.conf +++ b/dockerfiles/nginx/nginx.conf @@ -11,7 +11,15 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } + location /$SWAGGER_PATH/ { + proxy_pass http://backend:${BACKEND_PORT}/$SWAGGER_PATH/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location /api/ { + rewrite ^/api(/.*)$ $1 break; proxy_pass http://backend:${BACKEND_PORT}/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;