possibility to disable default location
This commit is contained in:
parent
2cc0a2fcf0
commit
82ce9223a9
3 changed files with 33 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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 -%>
|
||||
|
|
|
@ -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 -%>
|
||||
|
|
Loading…
Reference in a new issue