Skip to content

Commit

Permalink
Allow locations with try_files only
Browse files Browse the repository at this point in the history
This is already possible through location_custom_cfg with a manifest
that looks like:

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  location_custom_cfg => {
    'try_files' => '$uri $uri/ @rewrite',
  }
}

This change simplifies the part by allowing to use the try_files
directive on its own (without only in combination with, e.g., www_root):

nginx::resource::location { 'location name':
  location  => '/',
  vhost     => 'any vhost',
  try_files' => [ '$uri', '$uri/', '@rewrite' ],
}

That looks a bit better as know the user doesn't need to think about,
if he can use try_files or need to use location_custom_cfg in the current
context, anymore.

fixes voxpupuli#470
  • Loading branch information
FlorianSW authored and Oleksandr Moskalenko committed Oct 13, 2016
1 parent 3d6e796 commit 3a83a9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
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) and ($uwsgi == undef) and ($location_custom_cfg == undef) and ($internal == false)) {
if (($www_root == undef) and ($proxy == undef) and ($location_alias == undef) and ($stub_status == undef) and ($fastcgi == undef) and ($uwsgi == undef) and ($location_custom_cfg == undef) and ($internal == false) and ($try_files == undef)) {
fail('Cannot create a location reference without a www_root, proxy, location_alias, fastcgi, uwsgi, stub_status, internal, or location_custom_cfg defined')
}
if (($www_root != undef) and ($proxy != undef)) {
Expand Down Expand Up @@ -375,6 +375,8 @@
$content_real = template('nginx/vhost/locations/uwsgi.erb')
} elsif ($www_root != undef) {
$content_real = template('nginx/vhost/locations/directory.erb')
} elsif ($try_files != undef) {
$content_real = template('nginx/vhost/locations/try_files.erb')
} else {
$content_real = template('nginx/vhost/locations/empty.erb')
}
Expand Down
3 changes: 3 additions & 0 deletions templates/vhost/locations/try_files.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% if @try_files -%>
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
<% end -%>

0 comments on commit 3a83a9a

Please sign in to comment.