diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index d9804f2a3..c432f6fb9 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -97,6 +97,7 @@ # used for mp4 streaming. Default: false # [*flv*] - Indicates whether or not this loation can be # used for flv streaming. Default: false +# [*expires*] - Setup expires time for locations content # # # Actions: @@ -192,8 +193,9 @@ $auth_basic_user_file = undef, $rewrite_rules = [], $priority = 500, - $mp4 = false, - $flv = false, + $mp4 = false, + $flv = false, + $expires = undef, ) { $root_group = $::nginx::config::root_group @@ -341,6 +343,9 @@ if (($priority + 0) < 401) or (($priority + 0) > 899) { fail('$priority must be in the range 401-899.') } + if ($expires != undef) { + validate_string($expires) + } # # Shared Variables $ensure_real = $ensure ? { diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index 86c054d4a..2d91d103e 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -77,6 +77,12 @@ value: 'any', match: ' satisfy any;' }, + { + title: 'should set expires', + attr: 'expires', + value: '33d', + match: ' expires 33d;' + }, { title: 'should set location_allow', attr: 'location_allow', diff --git a/templates/vhost/location_header.erb b/templates/vhost/location_header.erb index cd3080573..1f84f5541 100644 --- a/templates/vhost/location_header.erb +++ b/templates/vhost/location_header.erb @@ -12,6 +12,9 @@ <% if @location_satisfy -%> satisfy <%= @location_satisfy -%>; <% end -%> +<% if @expires -%> + expires <%= @expires %>; +<% end -%> <% if @location_allow -%> <%- @location_allow.each do |allow_rule| -%> allow <%= allow_rule %>;