(#11667) add try_files support in vhost and location directives
Try_files is how NGINX files the files to serve particularly in a fallback mode. Using an array for try_files will interate through these options in the generated configuration file.
This commit is contained in:
parent
14d6281d5a
commit
719028ce5e
3 changed files with 17 additions and 8 deletions
|
@ -11,6 +11,7 @@
|
||||||
# [*proxy*] - Proxy server(s) for a location to connect to. Accepts a single value, can be used in conjunction
|
# [*proxy*] - Proxy server(s) for a location to connect to. Accepts a single value, can be used in conjunction
|
||||||
# with nginx::resource::upstream
|
# with nginx::resource::upstream
|
||||||
# [*ssl*] - Indicates whether to setup SSL bindings for this location.
|
# [*ssl*] - Indicates whether to setup SSL bindings for this location.
|
||||||
|
# [*try_files*] - An array of file locations to try
|
||||||
# [*option*] - Reserved for future use
|
# [*option*] - Reserved for future use
|
||||||
#
|
#
|
||||||
# Actions:
|
# Actions:
|
||||||
|
@ -31,6 +32,7 @@ define nginx::resource::location(
|
||||||
$index_files = ['index.html', 'index.htm', 'index.php'],
|
$index_files = ['index.html', 'index.htm', 'index.php'],
|
||||||
$proxy = undef,
|
$proxy = undef,
|
||||||
$ssl = false,
|
$ssl = false,
|
||||||
|
$try_files = undef,
|
||||||
$option = undef,
|
$option = undef,
|
||||||
$location
|
$location
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
# [*ssl_cert*] - Pre-generated SSL Certificate file to reference for SSL Support. This is not generated by this module.
|
# [*ssl_cert*] - Pre-generated SSL Certificate file to reference for SSL Support. This is not generated by this module.
|
||||||
# [*ssl_key*] - Pre-generated SSL Key file to reference for SSL Support. This is not generated by this module.
|
# [*ssl_key*] - Pre-generated SSL Key file to reference for SSL Support. This is not generated by this module.
|
||||||
# [*www_root*] - Specifies the location on disk for files to be read from. Cannot be set in conjunction with $proxy
|
# [*www_root*] - Specifies the location on disk for files to be read from. Cannot be set in conjunction with $proxy
|
||||||
|
# [*try_files*] - Specifies the locations for files to be checked as an array. Cannot be used in conjuction with $proxy.
|
||||||
#
|
#
|
||||||
# Actions:
|
# Actions:
|
||||||
#
|
#
|
||||||
|
@ -42,7 +43,8 @@ define nginx::resource::vhost(
|
||||||
$ssl_key = undef,
|
$ssl_key = undef,
|
||||||
$proxy = undef,
|
$proxy = undef,
|
||||||
$index_files = ['index.html', 'index.htm', 'index.php'],
|
$index_files = ['index.html', 'index.htm', 'index.php'],
|
||||||
$www_root = undef
|
$www_root = undef,
|
||||||
|
$try_files = undef
|
||||||
) {
|
) {
|
||||||
|
|
||||||
File {
|
File {
|
||||||
|
@ -77,13 +79,14 @@ define nginx::resource::vhost(
|
||||||
|
|
||||||
# Create the default location reference for the vHost
|
# Create the default location reference for the vHost
|
||||||
nginx::resource::location {"${name}-default":
|
nginx::resource::location {"${name}-default":
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
vhost => $name,
|
vhost => $name,
|
||||||
ssl => $ssl,
|
ssl => $ssl,
|
||||||
location => '/',
|
location => '/',
|
||||||
proxy => $proxy,
|
proxy => $proxy,
|
||||||
www_root => $www_root,
|
try_files => $try_files,
|
||||||
notify => Class['nginx::service'],
|
www_root => $www_root,
|
||||||
|
notify => Class['nginx::service'],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a proper file close stub.
|
# Create a proper file close stub.
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
location <%= location %> {
|
location <%= location %> {
|
||||||
root <%= www_root %>;
|
root <%= www_root %>;
|
||||||
index <% index_files.each do |i| %> <%= i %> <% end %>;
|
index <% index_files.each do |i| %> <%= i %> <% end %>;
|
||||||
|
|
||||||
|
<% if has_variable?("try_files") then %>
|
||||||
|
try_files <% try_files.each do |try| -%> <%= try %> <% end -%>;
|
||||||
|
<% end %>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue