From 5257e34b64fdd8c5e2f54a7bf20e0e7085cca0e6 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 5 Oct 2017 09:29:21 -0300 Subject: Adds cache support for SSL-enabled sites --- manifests/site.pp | 19 ++++++++++++------- templates/site-ssl.erb | 8 ++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/manifests/site.pp b/manifests/site.pp index 851d471..9997e97 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -1,11 +1,16 @@ define nginx::site( - $ensure = present, - $ssl = present, - $source = 'template', - $certbot = true, - $template = 'site', - $backend = 'weblocal', - $aliases = "*.${name}", + $ensure = present, + $ssl = present, + $source = 'template', + $certbot = true, + $template = 'site', + $backend = 'weblocal', + $aliases = "*.${name}", + $cache = false, + $cache_levels = '1:2', + $cache_size = '10m', + $cache_inactive = '600s', + $cache_max_size = '1m', ) { nginx::site::config { $name: ensure => $ensure, diff --git a/templates/site-ssl.erb b/templates/site-ssl.erb index c0af188..a370bc7 100644 --- a/templates/site-ssl.erb +++ b/templates/site-ssl.erb @@ -1,3 +1,6 @@ +<% if @cache == true -%> +proxy_cache_path /var/cache/nginx/<%= @name %> levels=<%= @cache_levels %> keys_zone=<%= @name %>:<%= @cache_size %> inactive=<%= @cache_inactive %> max_size=<%= @cache_max_size %>; +<% end -%> server { listen 443; server_name <%= @server_name %> <%= @aliases %>; @@ -16,5 +19,10 @@ server { # default proxy pass proxy_pass http://<%= @backend %>:80; +<% if @cache == true -%> + + # cache config + proxy_cache <%= @name %>; +<% end -%> } } -- cgit v1.2.3