Browse Source

Add use_temp_path into proxy_cache_path

see http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_path
Simon Stier 7 years ago
parent
commit
5a4f6069f9
3 changed files with 10 additions and 2 deletions
  1. 5 0
      manifests/config.pp
  2. 3 0
      manifests/init.pp
  3. 2 2
      templates/conf.d/nginx.conf.erb

+ 5 - 0
manifests/config.pp

@@ -82,6 +82,7 @@ class nginx::config(
   $proxy_cache_levels             = '1',
   $proxy_cache_max_size           = '500m',
   $proxy_cache_path               = false,
+  $proxy_use_temp_path            = false,
   $proxy_connect_timeout          = '90',
   $proxy_headers_hash_bucket_size = '64',
   $proxy_http_version             = undef,
@@ -143,6 +144,10 @@ class nginx::config(
   validate_string($proxy_cache_max_size)
   validate_string($proxy_cache_inactive)
 
+  if ($proxy_use_temp_path != false) {
+        validate_re($proxy_use_temp_path, '^(on|off)$')
+  }
+
   if ($fastcgi_cache_path != false) {
         validate_string($fastcgi_cache_path)
   }

+ 3 - 0
manifests/init.pp

@@ -54,6 +54,7 @@ class nginx (
   $proxy_cache_levels             = undef,
   $proxy_cache_max_size           = undef,
   $proxy_cache_path               = undef,
+  $proxy_use_temp_path            = undef,
   $proxy_connect_timeout          = undef,
   $proxy_headers_hash_bucket_size = undef,
   $proxy_http_version             = undef,
@@ -178,6 +179,7 @@ class nginx (
         $proxy_cache_levels or
         $proxy_cache_max_size or
         $proxy_cache_path or
+        $proxy_use_temp_path or
         $proxy_conf_template or
         $proxy_connect_timeout or
         $proxy_headers_hash_bucket_size or
@@ -260,6 +262,7 @@ class nginx (
       proxy_cache_levels             => $proxy_cache_levels,
       proxy_cache_max_size           => $proxy_cache_max_size,
       proxy_cache_path               => $proxy_cache_path,
+      proxy_use_temp_path            => $proxy_use_temp_path,
       proxy_conf_template            => $proxy_conf_template,
       proxy_connect_timeout          => $proxy_connect_timeout,
       proxy_headers_hash_bucket_size => $proxy_headers_hash_bucket_size,

+ 2 - 2
templates/conf.d/nginx.conf.erb

@@ -128,10 +128,10 @@ http {
 <% end -%>
 <% if @proxy_cache_path.is_a?(Hash) -%>
 <% @proxy_cache_path.sort_by{|k,v| k}.each do |key,value| -%>
-  proxy_cache_path        <%= key %> keys_zone=<%= value %> levels=<%= @proxy_cache_levels %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %>;
+  proxy_cache_path        <%= key %> keys_zone=<%= value %> levels=<%= @proxy_cache_levels %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %><% if @proxy_use_temp_path %> use_temp_path=<%= @proxy_use_temp_path %><% end -%>;
 <% end -%>
 <% elsif @proxy_cache_path -%>
-  proxy_cache_path        <%= @proxy_cache_path %> levels=<%= @proxy_cache_levels %> keys_zone=<%= @proxy_cache_keys_zone %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %>;
+  proxy_cache_path        <%= @proxy_cache_path %> levels=<%= @proxy_cache_levels %> keys_zone=<%= @proxy_cache_keys_zone %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %><% if @proxy_use_temp_path %> use_temp_path=<%= @proxy_use_temp_path %><% end %>;
 <% end -%>
 <% if @fastcgi_cache_path -%>
   fastcgi_cache_path    	<%= @fastcgi_cache_path %> levels=<%= @fastcgi_cache_levels %> keys_zone=<%= @fastcgi_cache_keys_zone %> max_size=<%= @fastcgi_cache_max_size %> inactive=<%= @fastcgi_cache_inactive %>;