Merge pull request #35 from hunner/add_tryfiles

Add try_files option
This commit is contained in:
James Fryman 2012-12-13 22:12:00 -08:00
commit 7c4041d143
5 changed files with 21 additions and 3 deletions

View file

@ -17,6 +17,7 @@
# [*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
# [*try_files*] - An array of file locations to try
# [*option*] - Reserved for future use
#
# Actions:
@ -60,6 +61,7 @@ define nginx::resource::location(
$stub_status = undef,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
$try_files = undef,
$location
) {
File {

View file

@ -25,6 +25,7 @@
# [*www_root*] - Specifies the location on disk for files to be read from. Cannot be set in conjunction with $proxy
# [*rewrite_www_to_non_www*] - Adds a server directive and rewrite rule to rewrite www.domain.com to domain.com in order to avoid
# duplicate content (SEO);
# [*try_files*] - Specifies the locations for files to be checked as an array. Cannot be used in conjuction with $proxy.
#
# Actions:
#
@ -59,6 +60,7 @@ define nginx::resource::vhost(
$rewrite_www_to_non_www = false,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
$try_files = undef
) {
File {
@ -106,6 +108,7 @@ define nginx::resource::vhost(
location => '/',
proxy => $proxy,
proxy_read_timeout => $proxy_read_timeout,
try_files => $try_files,
www_root => $www_root,
notify => Class['nginx::service'],
}

View file

@ -3,6 +3,9 @@
<%= key %> <%= value %>;
<% end -%><% end -%>
root <%= www_root %>;
<% if has_variable?("try_files") then %>
try_files <% try_files.each do |try| -%> <%= try %> <% end -%>;
<% end %>
index <% index_files.each do |i| %> <%= i %> <% end %>;
<% if @location_cfg_append -%><% location_cfg_append.each do |key,value| -%>
<%= key %> <%= value %>;

View file

@ -1,7 +1,9 @@
server {
listen <%= ssl_port %>;
<% if ipv6_enable == 'true' && (defined? ipaddress6) %>listen [<%= ipv6_listen_ip %>]:<%= ipv6_listen_port %> default ipv6only=on;<% end %>
server_name <%= name %>;
<% if ipv6_enable == 'true' && (defined? ipaddress6) %>
listen [<%= ipv6_listen_ip %>]:<%= ipv6_listen_port %> <% if @ipv6_listen_options %><%= ipv6_listen_options %><% end %> ipv6only=on;
<% end %>
server_name <%= rewrite_www_to_non_www ? name.gsub(/^www\./, '') : server_name.join(" ") %>;
ssl on;
ssl_certificate <%= ssl_cert %>;

View file

@ -1,4 +1,4 @@
include nginix
include nginx
nginx::resource::vhost { 'test.local':
ensure => present,
@ -6,3 +6,11 @@ nginx::resource::vhost { 'test.local':
proxy => 'http://proxypass',
}
nginx::resource::vhost { 'test.local:8080':
listen_port => 8080,
server_name => 'test.local',
ensure => present,
ipv6_enable => 'true',
proxy => 'http://proxypass',
}