diff --git a/states/nginx/config.sls b/states/nginx/config.sls index 821bb69..1fe0273 100644 --- a/states/nginx/config.sls +++ b/states/nginx/config.sls @@ -46,6 +46,7 @@ nginx-sites-available-{{ key }}: - service: nginx-service - context: vhost_name: {{ vhost.name }} + config_dir: {{ nginx.config.dir }} https: {{ vhost.https|default(true) }} proxy: {{ vhost.proxy|default(false) }} proxy_pass: {{ vhost.proxy_pass|default("") }} @@ -53,6 +54,7 @@ nginx-sites-available-{{ key }}: autoindex: {{ vhost.autoindex|default(false) }} root_dir: {{ vhost.root_dir|default(none) }} internal_access: {{ vhost.internal_access|default(false) }} + auth: {{ vhost.auth|default(false) }} dirs: {{ vhost.dirs|default([]) }} php_socket_file: {{ nginx.config.php_socket_file }} diff --git a/states/nginx/templates/types/simple.j2 b/states/nginx/templates/types/simple.j2 index 40c2296..d24a67e 100644 --- a/states/nginx/templates/types/simple.j2 +++ b/states/nginx/templates/types/simple.j2 @@ -29,6 +29,10 @@ server { {%- else %} index index.html index.rss; {% endif %} + {%- if auth %} + auth_basic "Restricted area"; + auth_basic_user_file {{ config_dir }}/auth/htpasswd; + {%- endif %} } {%- for dir in dirs %}