Skip to content

Commit 9b0eb08

Browse files
committed
fix: change redirects to remember base path
1 parent 27981ca commit 9b0eb08

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎config/templates/app/nginx.conf.j2‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ http {
4646

4747
access_log /dev/stdout main;
4848

49-
location {{ env.FRONTEND_BASE_URL }}api {
49+
absolute_redirect off;
50+
51+
52+
location {{ env.FRONTEND_BASE_URL }}api/ {
5053
include /etc/nginx/uwsgi_params;
5154
uwsgi_pass backend;
5255

@@ -66,7 +69,7 @@ http {
6669

6770
{% if env.FRONTEND_BASE_URL != '/' -%}
6871
location / {
69-
return 301 {{ env.FRONTEND_BASE_URL }};
72+
return 301 {{ env.FRONTEND_BASE_URL[:-1] }}$request_uri;
7073
}
7174
{%- endif %}
7275
}

‎docker-entrypoint.sh‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ JINJA2="import os, sys, jinja2; sys.stdout.write(jinja2.Template(sys.stdin.read(
44

55
ALERTA_CONF_FILE=${ALERTA_CONF_FILE:-/app/alerta.conf}
66
ALERTA_SVR_CONF_FILE=${ALERTA_SVR_CONF_FILE:-/app/alertad.conf}
7-
ALERTA_WEB_CONF_FILE=/web${FRONTEND_BASE_URL}config.json
87
NGINX_CONF_FILE=/app/nginx.conf
98
UWSGI_CONF_FILE=/app/uwsgi.ini
109
SUPERVISORD_CONF_FILE=/app/supervisord.conf
@@ -17,6 +16,14 @@ ADMIN_USER=${ADMIN_USERS%%,*}
1716
ADMIN_PASSWORD=${ADMIN_PASSWORD:-alerta}
1817
MAXAGE=${ADMIN_KEY_MAXAGE:-315360000} # default=10 years
1918

19+
# Make sure that FRONTEND_BASE_URL ends with a /
20+
if [[ "${FRONTEND_BASE_URL: -1}" != "/" ]]; then
21+
if [ $INIT_LOG = true ]; then echo "# Fixed FRONTEND_BASE_URL by adding a '/' at the end"; fi
22+
export FRONTEND_BASE_URL=${FRONTEND_BASE_URL}/
23+
fi
24+
25+
ALERTA_WEB_CONF_FILE=/web${FRONTEND_BASE_URL}config.json
26+
2027
# Generate minimal server config, if not supplied
2128
if [ ! -f "${ALERTA_SVR_CONF_FILE}" ]; then
2229
if [ $INIT_LOG = true ]; then echo "# Create server configuration file."; fi

0 commit comments

Comments
 (0)