diff --git a/software/slaprunner/common.cfg b/software/slaprunner/common.cfg index 7a1a478a9349a6e50da4f1c0eabf1d0eaf63cd03..1ad9cf473bd82db4495620f3ce53717e887d9181 100644 --- a/software/slaprunner/common.cfg +++ b/software/slaprunner/common.cfg @@ -102,7 +102,7 @@ mode = 0644 recipe = hexagonit.recipe.download url = ${:_profile_base_location_}/nginx_conf.in download-only = true -md5sum = fac41d8819c17ebca78e4554932b1075 +md5sum = 5bbe62827d232b3bbac3d5eb03e2d648 filename = nginx_conf.in mode = 0644 diff --git a/software/slaprunner/nginx_conf.in b/software/slaprunner/nginx_conf.in index 961469fc50ef86fbc9547bb3901b3cd53f63d7d5..cbfd9e7287d51433be6516e92cc5651ac33e1868 100644 --- a/software/slaprunner/nginx_conf.in +++ b/software/slaprunner/nginx_conf.in @@ -36,6 +36,17 @@ http { location / { # When no .htpasswd exist, redirect the user to account creation page if ( !-f {{ param_nginx_frontend['etc_dir'] }}/.htpasswd ) { + # redirect URL is different wether nginx is accessed directly or behind apache. + # nginx does not support nested if or multiple conditions, so we use this well known hack. + set $test no_htpasswd; + } + if ( $host = [{{ param_nginx_frontend['global-ip'] }}] ) { + set $test "${test}_backend_access"; + } + if ( $test = no_htpasswd) { + return 301 $scheme://$host/setAccount ; + } + if ( $test = no_htpasswd_backend_access) { return 301 /setAccount ; } auth_basic "Restricted";