From 171b7d0cce4bbf715c76ff7acae48fc3561b3b38 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Fri, 15 Feb 2019 14:59:38 +0100 Subject: [PATCH] Add root parameter to server context (#104) * Add root parameter to server context * Update NGINX Unit test playbook --- README.md | 1 + defaults/main.yml | 1 + templates/http/default.conf.j2 | 10 ++++++---- tests/playbooks/nginx-unit.yml | 1 - 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9a297e5..ec18524 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,7 @@ nginx_http_template: port: 8081 server_name: localhost error_page: /usr/share/nginx/html + root: /usr/share/nginx/html https_redirect: false autoindex: false ssl: diff --git a/defaults/main.yml b/defaults/main.yml index 3dff67f..c6e23bb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -163,6 +163,7 @@ nginx_http_template: port: 8081 server_name: localhost error_page: /usr/share/nginx/html + root: /usr/share/nginx/html https_redirect: false autoindex: false ssl: diff --git a/templates/http/default.conf.j2 b/templates/http/default.conf.j2 index 36edf31..13d728d 100644 --- a/templates/http/default.conf.j2 +++ b/templates/http/default.conf.j2 @@ -56,13 +56,15 @@ server { listen {{ item.value.port }}; {% endif %} server_name {{ item.value.server_name }}; -{% if item.value.autoindex is defined and item.value.autoindex %} - autoindex on; +{% if item.value.root is defined and item.value.root %} + root {{ item.value.root }}; {% endif %} {% if item.value.https_redirect is defined and item.value.https_redirect %} return 301 https://{{ item.value.server_name }}$request_uri; -{% endif%} - +{% endif %} +{% if item.value.autoindex is defined and item.value.autoindex %} + autoindex on; +{% endif %} {% if item.value.reverse_proxy is defined %} {% for location in item.value.reverse_proxy.locations %} location {{ item.value.reverse_proxy.locations[location].location }} { diff --git a/tests/playbooks/nginx-unit.yml b/tests/playbooks/nginx-unit.yml index 82e4900..bedd0a6 100644 --- a/tests/playbooks/nginx-unit.yml +++ b/tests/playbooks/nginx-unit.yml @@ -9,4 +9,3 @@ nginx_unit_enable: true nginx_unit_modules: - unit-php - - unit-perl