Add support for locations with only custom directives
This commit is contained in:
parent
063f6b5670
commit
d83822810e
2 changed files with 16 additions and 6 deletions
|
@ -18,8 +18,9 @@
|
|||
# [*ssl_only*] - Required if the SSL and normal vHost have the same port.
|
||||
# [*location_alias*] - Path to be used as basis for serving requests for this location
|
||||
# [*stub_status*] - If true it will point configure module stub_status to provide nginx stats on location
|
||||
# [*location_cfg_prepend*] - It expects a hash with custom directives to put before anything else inside location
|
||||
# [*location_cfg_append*] - It expects a hash with custom directives to put after everything else inside location
|
||||
# [*custom_cfg*] - Expects a hash with custom directives, cannot be used with other location types (proxy, fastcgi, root, or stub_status)
|
||||
# [*location_cfg_prepend*] - Expects a hash with extra directives to put before anything else inside location (used with all other types except custom_cfg)
|
||||
# [*location_cfg_append*] - Expects a hash with extra directives to put after everything else inside location (used with all other types except custom_cfg)
|
||||
# [*try_files*] - An array of file locations to try
|
||||
# [*option*] - Reserved for future use
|
||||
# [*proxy_cache*] - This directive sets name of zone for caching.
|
||||
|
@ -77,6 +78,7 @@ define nginx::resource::location (
|
|||
$location_alias = undef,
|
||||
$option = undef,
|
||||
$stub_status = undef,
|
||||
$custom_cfg = undef,
|
||||
$location_cfg_prepend = undef,
|
||||
$location_cfg_append = undef,
|
||||
$try_files = undef,
|
||||
|
@ -98,14 +100,15 @@ define nginx::resource::location (
|
|||
default => file,
|
||||
}
|
||||
|
||||
notice "custom_cfg ${custom_cfg}"
|
||||
|
||||
## Check for various error conditions
|
||||
if ($vhost == undef) {
|
||||
fail('Cannot create a location reference without attaching to a virtual host')
|
||||
}
|
||||
if (($www_root == undef) and ($proxy == undef) and ($location_alias == undef) and ($stub_status == undef) and ($fastcgi == undef)) {
|
||||
fail('Cannot create a location reference without a www_root, proxy, location_alias, fastcgi or stub_status defined')
|
||||
if (($www_root == undef) and ($proxy == undef) and ($location_alias == undef) and ($stub_status == undef) and ($fastcgi == undef) and ($custom_cfg == undef)) {
|
||||
fail('Cannot create a location reference without a www_root, proxy, location_alias, fastcgi, stub_status, or custom_cfg defined')
|
||||
}
|
||||
|
||||
if (($www_root != undef) and ($proxy != undef)) {
|
||||
fail('Cannot define both directory and proxy in a virtual host')
|
||||
}
|
||||
|
@ -119,8 +122,10 @@ define nginx::resource::location (
|
|||
$content_real = template('nginx/vhost/vhost_location_stub_status.erb')
|
||||
} elsif ($fastcgi != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_fastcgi.erb')
|
||||
} else {
|
||||
} elsif ($www_root != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_directory.erb')
|
||||
} else {
|
||||
$content_real = template('nginx/vhost/vhost_location_empty.erb')
|
||||
}
|
||||
|
||||
## Create stubs for vHost File Fragment Pattern
|
||||
|
|
5
templates/vhost/vhost_location_empty.erb
Normal file
5
templates/vhost/vhost_location_empty.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
location <%= location %> {
|
||||
<% custom_cfg.each do |key,value| -%>
|
||||
<%= key %> <%= value %>;
|
||||
<% end -%>
|
||||
}
|
Loading…
Reference in a new issue