Skip to content

Commit

Permalink
Merge pull request #35 from hunner/add_tryfiles
Browse files Browse the repository at this point in the history
Add try_files option
  • Loading branch information
James Fryman committed Dec 14, 2012
2 parents b4c02e2 + e419006 commit 7c4041d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -60,6 +61,7 @@
$stub_status = undef,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
$try_files = undef,
$location
) {
File {
Expand Down
3 changes: 3 additions & 0 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -59,6 +60,7 @@
$rewrite_www_to_non_www = false,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
$try_files = undef
) {

File {
Expand Down Expand Up @@ -106,6 +108,7 @@
location => '/',
proxy => $proxy,
proxy_read_timeout => $proxy_read_timeout,
try_files => $try_files,
www_root => $www_root,
notify => Class['nginx::service'],
}
Expand Down
3 changes: 3 additions & 0 deletions templates/vhost/vhost_location_directory.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>;
Expand Down
6 changes: 4 additions & 2 deletions templates/vhost/vhost_ssl_header.erb
Original file line number Diff line number Diff line change
@@ -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 %>;
Expand Down
10 changes: 9 additions & 1 deletion tests/vhost.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
include nginix
include nginx

nginx::resource::vhost { 'test.local':
ensure => present,
ipv6_enable => 'true',
proxy => 'http://proxypass',
}

nginx::resource::vhost { 'test.local:8080':
listen_port => 8080,
server_name => 'test.local',
ensure => present,
ipv6_enable => 'true',
proxy => 'http://proxypass',
}

0 comments on commit 7c4041d

Please sign in to comment.