diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index d88052a9b..4012a76ce 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -27,8 +27,8 @@ # response code is equal to 200, 204, 301, 302 or 304. # [*index_files*] - Default index files for NGINX to read when # traversing a directory -# [*autoindex*] - Set it on 'on' to activate autoindex directory -# listing. Undef by default. +# [*autoindex*] - Set it on 'on' or 'off 'to activate/deactivate +# autoindex directory listing. Undef by default. # [*proxy*] - Proxy server(s) for the root location to connect # to. Accepts a single value, can be used in conjunction with # nginx::resource::upstream @@ -392,6 +392,7 @@ fastcgi_script => $fastcgi_script, try_files => $try_files, www_root => $www_root, + autoindex => $autoindex, index_files => [], location_custom_cfg => $location_custom_cfg, notify => Class['nginx::service'], diff --git a/templates/vhost/vhost_location_directory.erb b/templates/vhost/vhost_location_directory.erb index c0995b0d2..36874abbf 100644 --- a/templates/vhost/vhost_location_directory.erb +++ b/templates/vhost/vhost_location_directory.erb @@ -17,8 +17,8 @@ <% if @try_files -%> try_files<% @try_files.each do |try| -%> <%= try %><% end -%>; <% end -%> -<% if @autoindex == 'on' -%> - autoindex on; +<% if defined? @autoindex -%> + autoindex <%= @autoindex %>; <% end -%> <% if @index_files.count > 0 -%> index <% Array(@index_files).each do |i| %> <%= i %><% end %>;