From 6c318b6fe4264a277fa130b5a25cf5e6c99236cc Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Wed, 6 Nov 2019 00:18:38 +0000 Subject: [PATCH] nginx: allow custom cache folder path, apply on longma --- cookbooks/nginx/attributes/default.rb | 2 ++ cookbooks/nginx/recipes/default.rb | 6 ++++-- cookbooks/nginx/templates/default/nginx.conf.erb | 4 ++-- roles/longma.rb | 7 +++++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cookbooks/nginx/attributes/default.rb b/cookbooks/nginx/attributes/default.rb index 30eb12bcc..c6e77de0a 100644 --- a/cookbooks/nginx/attributes/default.rb +++ b/cookbooks/nginx/attributes/default.rb @@ -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" diff --git a/cookbooks/nginx/recipes/default.rb b/cookbooks/nginx/recipes/default.rb index ae6fb2362..93aab5690 100644 --- a/cookbooks/nginx/recipes/default.rb +++ b/cookbooks/nginx/recipes/default.rb @@ -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 diff --git a/cookbooks/nginx/templates/default/nginx.conf.erb b/cookbooks/nginx/templates/default/nginx.conf.erb index 7422f2f20..a3f6b2411 100644 --- a/cookbooks/nginx/templates/default/nginx.conf.erb +++ b/cookbooks/nginx/templates/default/nginx.conf.erb @@ -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 diff --git a/roles/longma.rb b/roles/longma.rb index 6639332e3..0cf93f0cb 100644 --- a/roles/longma.rb +++ b/roles/longma.rb @@ -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 => [ -- 2.43.2