Skip to content

Commit

Permalink
Merge pull request voxpupuli#636 from jacobmw/vhost_cache
Browse files Browse the repository at this point in the history
Vhost and loation proxy_cache_key and proxy_cache_use_stale
  • Loading branch information
3flex committed Jun 2, 2015
2 parents 26b5361 + bc5e0f2 commit 0957af0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
12 changes: 12 additions & 0 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
# [*option*] - Reserved for future use
# [*proxy_cache*] - This directive sets name of zone for caching.
# The same zone can be used in multiple places.
# [*proxy_cache_key*] - Override the default proxy_cache_key of
# $scheme$proxy_host$request_uri
# [*proxy_cache_use_stale*] - Override the default proxy_cache_use_stale value
# of off.
# [*proxy_cache_valid*] - This directive sets the time for caching
# different replies.
# [*proxy_method*] - If defined, overrides the HTTP method of the
Expand Down Expand Up @@ -166,6 +170,8 @@
$include = undef,
$try_files = undef,
$proxy_cache = false,
$proxy_cache_key = undef,
$proxy_cache_use_stale = undef,
$proxy_cache_valid = false,
$proxy_method = undef,
$proxy_set_body = undef,
Expand Down Expand Up @@ -277,6 +283,12 @@
if ($proxy_cache != false) {
validate_string($proxy_cache)
}
if ($proxy_cache_key != undef) {
validate_string($proxy_cache_key)
}
if ($proxy_cache_use_stale != undef) {
validate_string($proxy_cache_use_stale)
}
if ($proxy_cache_valid != false) {
validate_string($proxy_cache_valid)
}
Expand Down
14 changes: 14 additions & 0 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
# checked as an array. Cannot be used in conjuction with $proxy.
# [*proxy_cache*] - This directive sets name of zone for caching.
# The same zone can be used in multiple places.
# [*proxy_cache_key*] - Override the default proxy_cache_key of
# $scheme$proxy_host$request_uri
# [*proxy_cache_use_stale*] - Override the default proxy_cache_use_stale value
# of off.
# [*proxy_cache_valid*] - This directive sets the time for caching
# different replies.
# [*proxy_method*] - If defined, overrides the HTTP method of the
Expand Down Expand Up @@ -193,6 +197,8 @@
$proxy_connect_timeout = $::nginx::config::proxy_connect_timeout,
$proxy_set_header = [],
$proxy_cache = false,
$proxy_cache_key = undef,
$proxy_cache_use_stale = undef,
$proxy_cache_valid = false,
$proxy_method = undef,
$proxy_set_body = undef,
Expand Down Expand Up @@ -322,6 +328,12 @@
if ($proxy_cache != false) {
validate_string($proxy_cache)
}
if ($proxy_cache_key != undef) {
validate_string($proxy_cache_key)
}
if ($proxy_cache_use_stale != undef) {
validate_string($proxy_cache_use_stale)
}
if ($proxy_cache_valid != false) {
validate_string($proxy_cache_valid)
}
Expand Down Expand Up @@ -530,6 +542,8 @@
proxy_read_timeout => $proxy_read_timeout,
proxy_connect_timeout => $proxy_connect_timeout,
proxy_cache => $proxy_cache,
proxy_cache_key => $proxy_cache_key,
proxy_cache_use_stale => $proxy_cache_use_stale,
proxy_cache_valid => $proxy_cache_valid,
proxy_method => $proxy_method,
proxy_set_header => $proxy_set_header,
Expand Down
14 changes: 13 additions & 1 deletion spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,19 @@
:value => false,
:notmatch => /proxy_cache\b/
},
{
{
:title => 'should set proxy_cache_key',
:attr => 'proxy_cache_key',
:value => 'value',
:match => /^\s+proxy_cache_key\s+value;/,
},
{
:title => 'should set proxy_cache_use_stale',
:attr => 'proxy_cache_use_stale',
:value => 'value',
:match => /^\s+proxy_cache_use_stale\s+value;/
},
{
:title => 'should set proxy_pass',
:attr => 'proxy',
:value => 'value',
Expand Down
6 changes: 6 additions & 0 deletions templates/vhost/locations/proxy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@
<% if @proxy_cache_valid -%>
proxy_cache_valid <%= @proxy_cache_valid %>;
<% end -%>
<% if @proxy_cache_use_stale -%>
proxy_cache_use_stale <%= @proxy_cache_use_stale %>;
<% end -%>
<% if @proxy_cache_key -%>
proxy_cache_key <%= @proxy_cache_key %>;
<% end -%>

0 comments on commit 0957af0

Please sign in to comment.