nginx: allow custom cache folder path, apply on longma
authorGrant Slater <git@firefishy.com>
Wed, 6 Nov 2019 00:18:38 +0000 (00:18 +0000)
committerGrant Slater <git@firefishy.com>
Wed, 6 Nov 2019 00:18:38 +0000 (00:18 +0000)
cookbooks/nginx/attributes/default.rb
cookbooks/nginx/recipes/default.rb
cookbooks/nginx/templates/default/nginx.conf.erb
roles/longma.rb

index 30eb12b..c6e77de 100644 (file)
@@ -3,12 +3,14 @@ default[:nginx][:access_log] = "/var/log/nginx/access.log"
 
 # Tuning for nginx fastcgi cache zone
 default[:nginx][:cache][:fastcgi][:enable] = false
+default[:nginx][:cache][:fastcgi][:directory] = "/var/cache/nginx/fastcgi-cache"
 default[:nginx][:cache][:fastcgi][:keys_zone] = "fastcgi_cache_zone:48M"
 default[:nginx][:cache][:fastcgi][:inactive] = "45d"
 default[:nginx][:cache][:fastcgi][:max_size] = "8192M"
 
 # Tuning for nginx proxy cache zone
 default[:nginx][:cache][:proxy][:enable] = false
+default[:nginx][:cache][:proxy][:directory] = "/var/cache/nginx/proxy-cache"
 default[:nginx][:cache][:proxy][:keys_zone] = "proxy_cache_zone:48M"
 default[:nginx][:cache][:proxy][:inactive] = "45d"
 default[:nginx][:cache][:proxy][:max_size] = "8192M"
index ae6fb23..93aab56 100644 (file)
@@ -31,17 +31,19 @@ template "/etc/nginx/nginx.conf" do
   variables :resolvers => resolvers
 end
 
-directory "/var/cache/nginx/fastcgi-cache" do
+directory node[:nginx][:cache][:fastcgi][:directory] do
   owner "www-data"
   group "root"
   mode 0o755
+  recursive true
   only_if { node[:nginx][:cache][:fastcgi][:enable] }
 end
 
-directory "/var/cache/nginx/proxy-cache" do
+directory node[:nginx][:cache][:proxy][:directory] do
   owner "www-data"
   group "root"
   mode 0o755
+  recursive true
   only_if { node[:nginx][:cache][:proxy][:enable] }
 end
 
index 7422f2f..a3f6b24 100644 (file)
@@ -51,10 +51,10 @@ http {
     resolver_timeout 5s;
 
     <% if node['nginx']['cache']['fastcgi']['enable'] -%>
-    fastcgi_cache_path /var/cache/nginx/fastcgi-cache levels=2:2:2 use_temp_path=off keys_zone=<%= node['nginx']['cache']['fastcgi']['keys_zone'] %> inactive=<%= node['nginx']['cache']['fastcgi']['inactive'] %> max_size=<%= node['nginx']['cache']['fastcgi']['max_size'] %>;
+    fastcgi_cache_path <%= node['nginx']['cache']['fastcgi']['directory'] %> levels=2:2:2 use_temp_path=off keys_zone=<%= node['nginx']['cache']['fastcgi']['keys_zone'] %> inactive=<%= node['nginx']['cache']['fastcgi']['inactive'] %> max_size=<%= node['nginx']['cache']['fastcgi']['max_size'] %>;
     <% end -%>
     <% if node['nginx']['cache']['proxy']['enable'] -%>
-    proxy_cache_path /var/cache/nginx/proxy-cache levels=2:2:2 use_temp_path=off keys_zone=<%= node['nginx']['cache']['proxy']['keys_zone'] %> inactive=<%= node['nginx']['cache']['proxy']['inactive'] %> max_size=<%= node['nginx']['cache']['proxy']['max_size'] %>;
+    proxy_cache_path <%= node['nginx']['cache']['proxy']['directory'] %> levels=2:2:2 use_temp_path=off keys_zone=<%= node['nginx']['cache']['proxy']['keys_zone'] %> inactive=<%= node['nginx']['cache']['proxy']['inactive'] %> max_size=<%= node['nginx']['cache']['proxy']['max_size'] %>;
     <% end -%>
 
     # Internal site for munin monitoring
index 6639332..0cf93f0 100644 (file)
@@ -31,6 +31,13 @@ default_attributes(
     :cache_mem => "12500 MB",
     :cache_dir => "coss /store/squid/coss-01 128000 block-size=8192 max-size=262144 membufs=80"
   },
+  :nginx => {
+    :cache => {
+      :proxy => {
+        :directory => "/store/nginx-cache/proxy-cache"
+      }
+    }
+  },
   :tilecache => {
     :tile_parent => "hsinchu.render.openstreetmap.org",
     :tile_siblings => [