From b844efca8c1edeccdc70f881849553c709f5bbc0 Mon Sep 17 00:00:00 2001 From: bax1489 <fabian.gallenkamp@uni-hamburg.de> Date: Fri, 4 Oct 2019 11:46:09 +0200 Subject: [PATCH] added 403 option, if redirection not defined --- configure_nginx.yml | 4 +++- configure_otree.yml | 2 +- templates/nginx_default_site.conf.j2 | 2 +- templates/supervisor_otree.conf.j2 | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/configure_nginx.yml b/configure_nginx.yml index 0ec77d1..73e4899 100755 --- a/configure_nginx.yml +++ b/configure_nginx.yml @@ -40,6 +40,7 @@ owner: root group: root mode: "0644" + notify: restart nginx - name: create symlinks for nginx vhosts confs file: @@ -61,6 +62,7 @@ group: root mode: "0644" with_dict: "{{ otree_users }}" + notify: restart nginx - name: create symlinks for nginx vhosts confs file: @@ -87,5 +89,5 @@ - name: restart nginx service: name: nginx - state: restarted + state: reloaded diff --git a/configure_otree.yml b/configure_otree.yml index addc912..9173971 100755 --- a/configure_otree.yml +++ b/configure_otree.yml @@ -134,7 +134,7 @@ chdir: "{{ home_path }}/{{ item.key }}/otree/" executable: /bin/bash environment: - DATABASE_URL: "{{ item.value.database }}" + DATABASE_URL: "postgres://{{ item.key }}:{{ item.value.admin_pw }}@localhost:5432/instance_{{ item.key }}" REDIS_URL: "{{ item.value.redis }}" OTREE_ADMIN_PASSWORD: "{{ item.value.admin_pw }}" OTREE_AUTH_LEVEL: "{{ item.value.auth_level }}" diff --git a/templates/nginx_default_site.conf.j2 b/templates/nginx_default_site.conf.j2 index 02e732d..c30882b 100755 --- a/templates/nginx_default_site.conf.j2 +++ b/templates/nginx_default_site.conf.j2 @@ -21,7 +21,7 @@ server { ssl_certificate_key {{ ssl_certificate_key_path }}; location / { - return 301 {{ default_redirection }}; + return {% if default_redirection is defined %}301 {{ default_redirection }}{% else %}403{% endif %}; } } diff --git a/templates/supervisor_otree.conf.j2 b/templates/supervisor_otree.conf.j2 index dd11159..bf36ae2 100755 --- a/templates/supervisor_otree.conf.j2 +++ b/templates/supervisor_otree.conf.j2 @@ -1,7 +1,7 @@ [program:{{ item.key }}] directory={{ home_path }}/{{ item.key }}/otree/ command=/bin/bash -c "source {{ home_path }}/{{ item.key }}/.venv_otree/bin/activate && otree runprodserver" -environment=DATABASE_URL="{{ item.value.database }}",REDIS_URL="{{ item.value.redis }}",OTREE_ADMIN_PASSWORD="{{ item.value.admin_pw }}",OTREE_AUTH_LEVEL="{{ item.value.auth_level }}",OTREE_SECRET_KEY="{{ item.value.secret_key }}",OTREE_PRODUCTION="{{ item.value.production }}",PORT={{ item.value.port }} +environment=DATABASE_URL="postgres://{{ item.key }}:{{ item.value.admin_pw }}@localhost:5432/instance_{{ item.key }}",REDIS_URL="{{ item.value.redis }}",OTREE_ADMIN_PASSWORD="{{ item.value.admin_pw }}",OTREE_AUTH_LEVEL="{{ item.value.auth_level }}",OTREE_SECRET_KEY="{{ item.value.secret_key }}",OTREE_PRODUCTION="{{ item.value.production }}",PORT={{ item.value.port }} autostart=true autorestart=true startretries=3 -- GitLab