diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index 66a4cbf..a31223b 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -135,6 +135,7 @@ define nginx::resource::vhost ( $access_log = undef, $error_log = undef, $passenger_cgi_param = undef, + $use_default_location = true, ) { validate_array($location_allow) @@ -193,28 +194,32 @@ define nginx::resource::vhost ( if ($ssl == true) and ($ssl_port == $listen_port) { $ssl_only = true } - - # Create the default location reference for the vHost - nginx::resource::location {"${name}-default": - ensure => $ensure, - vhost => $name, - ssl => $ssl, - ssl_only => $ssl_only, - location => '/', - location_allow => $location_allow, - location_deny => $location_deny, - proxy => $proxy, - proxy_read_timeout => $proxy_read_timeout, - proxy_cache => $proxy_cache, - proxy_cache_valid => $proxy_cache_valid, - fastcgi => $fastcgi, - fastcgi_params => $fastcgi_params, - fastcgi_script => $fastcgi_script, - try_files => $try_files, - www_root => $www_root, - index_files => $index_files, - location_custom_cfg => $location_custom_cfg, - notify => Class['nginx::service'], + + if $use_default_location == true { + # Create the default location reference for the vHost + nginx::resource::location {"${name}-default": + ensure => $ensure, + vhost => $name, + ssl => $ssl, + ssl_only => $ssl_only, + location => '/', + location_allow => $location_allow, + location_deny => $location_deny, + proxy => $proxy, + proxy_read_timeout => $proxy_read_timeout, + proxy_cache => $proxy_cache, + proxy_cache_valid => $proxy_cache_valid, + fastcgi => $fastcgi, + fastcgi_params => $fastcgi_params, + fastcgi_script => $fastcgi_script, + try_files => $try_files, + www_root => $www_root, + index_files => $index_files, + location_custom_cfg => $location_custom_cfg, + notify => Class['nginx::service'], + } + } else { + $root = $www_root } # Support location_cfg_prepend and location_cfg_append on default location created by vhost diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index f8d3717..ae0217d 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -17,6 +17,9 @@ server { <% if @vhost_cfg_prepend -%><% vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%= key %> <%= value %>; <% end -%><% end -%> +<% if @root -%> + root <%= @root %>; +<% end -%> <% if @passenger_cgi_param -%><% @passenger_cgi_param.each do |key,value| -%> passenger_set_cgi_param <%= key %> <%= value %>; <% end -%><% end -%> diff --git a/templates/vhost/vhost_ssl_header.erb b/templates/vhost/vhost_ssl_header.erb index e51125e..2de8b1e 100644 --- a/templates/vhost/vhost_ssl_header.erb +++ b/templates/vhost/vhost_ssl_header.erb @@ -24,6 +24,9 @@ server { access_log <%= @ssl_access_log %>; error_log <%= @ssl_error_log %>; +<% if @root -%> + root <%= @root %>; +<% end -%> <% if @passenger_cgi_param -%><% @passenger_cgi_param.each do |key,value| -%> passenger_set_cgi_param <%= key %> <%= value %>; <% end -%><% end -%>