Commit 83e98540 authored by Jérome Perrin's avatar Jérome Perrin

slaprunner: fix 401 http errors when no account exist

If no htpasswd file exist, redirect to account creation page
parent 86704f26
...@@ -102,7 +102,7 @@ mode = 0644 ...@@ -102,7 +102,7 @@ mode = 0644
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/nginx_conf.in url = ${:_profile_base_location_}/nginx_conf.in
download-only = true download-only = true
md5sum = 00b902364c32ef21a28461716700fb2b md5sum = fac41d8819c17ebca78e4554932b1075
filename = nginx_conf.in filename = nginx_conf.in
mode = 0644 mode = 0644
......
...@@ -6,8 +6,8 @@ error_log {{ param_nginx_frontend['path_error_log'] }}; ...@@ -6,8 +6,8 @@ error_log {{ param_nginx_frontend['path_error_log'] }};
daemon off; daemon off;
events { events {
worker_connections 1024; worker_connections 1024;
accept_mutex off; accept_mutex off;
} }
http { http {
...@@ -18,6 +18,7 @@ http { ...@@ -18,6 +18,7 @@ http {
default upgrade; default upgrade;
'' close; '' close;
} }
server { server {
listen [{{ param_nginx_frontend['global-ip'] }}]:{{ param_nginx_frontend['global-port'] }} ssl; listen [{{ param_nginx_frontend['global-ip'] }}]:{{ param_nginx_frontend['global-port'] }} ssl;
server_name _; server_name _;
...@@ -31,8 +32,12 @@ http { ...@@ -31,8 +32,12 @@ http {
fastcgi_temp_path {{ param_tempdir['fastcgi_temp_path'] }}; fastcgi_temp_path {{ param_tempdir['fastcgi_temp_path'] }};
uwsgi_temp_path {{ param_tempdir['uwsgi_temp_path'] }}; uwsgi_temp_path {{ param_tempdir['uwsgi_temp_path'] }};
scgi_temp_path {{ param_tempdir['scgi_temp_path'] }}; scgi_temp_path {{ param_tempdir['scgi_temp_path'] }};
error_page 401 /login;
location / { location / {
# When no .htpasswd exist, redirect the user to account creation page
if ( !-f {{ param_nginx_frontend['etc_dir'] }}/.htpasswd ) {
return 301 /setAccount ;
}
auth_basic "Restricted"; auth_basic "Restricted";
auth_basic_user_file {{ param_nginx_frontend['etc_dir'] }}/.htpasswd; auth_basic_user_file {{ param_nginx_frontend['etc_dir'] }}/.htpasswd;
proxy_redirect off; proxy_redirect off;
...@@ -52,7 +57,6 @@ http { ...@@ -52,7 +57,6 @@ http {
proxy_pass http://unix:{{ socket }}; proxy_pass http://unix:{{ socket }};
} }
location /shellinabox { location /shellinabox {
proxy_pass http://unix:{{ shellinabox_socket }}:/; proxy_pass http://unix:{{ shellinabox_socket }}:/;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment