From 35577ccc887ca6848fbf604087e5fb87999fed02 Mon Sep 17 00:00:00 2001 From: Matthew Haughton Date: Sat, 11 Jul 2015 16:28:43 -0400 Subject: [PATCH] add remaining gzip directives Closes #367 --- manifests/config.pp | 8 +++++ spec/classes/config_spec.rb | 56 ++++++++++++++++++++++++++++++++- templates/conf.d/nginx.conf.erb | 19 +++++++++-- 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index cc6954eef..d2c17c6b0 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -53,6 +53,14 @@ $fastcgi_cache_path = false, $fastcgi_cache_use_stale = false, $gzip = 'on', + $gzip_buffers = undef, + $gzip_comp_level = 1, + $gzip_disable = 'msie6', + $gzip_min_length = 20, + $gzip_http_version = 1.1, + $gzip_proxied = 'off', + $gzip_types = 'text/html', + $gzip_vary = 'off', $http_cfg_append = false, $http_tcp_nodelay = 'on', $http_tcp_nopush = 'off', diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index fc7d0c6cb..1440f722a 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -236,7 +236,7 @@ :title => 'should set gzip', :attr => 'gzip', :value => 'on', - :match => ' gzip on;', + :match => ' gzip on;', }, { :title => 'should not set gzip', @@ -244,6 +244,60 @@ :value => 'off', :notmatch => /gzip/, }, + { + :title => 'should set gzip_buffers', + :attr => 'gzip_buffers', + :value => '32 4k', + :match => ' gzip_buffers 32 4k;', + }, + { + :title => 'should set gzip_comp_level', + :attr => 'gzip_comp_level', + :value => 5, + :match => ' gzip_comp_level 5;', + }, + { + :title => 'should set gzip_disable', + :attr => 'gzip_disable', + :value => 'MSIE [1-6]\.(?!.*SV1)', + :match => ' gzip_disable MSIE [1-6]\.(?!.*SV1);', + }, + { + :title => 'should set gzip_min_length', + :attr => 'gzip_min_length', + :value => '10', + :match => ' gzip_min_length 10;', + }, + { + :title => 'should set gzip_http_version', + :attr => 'gzip_http_version', + :value => '1.0', + :match => ' gzip_http_version 1.0;', + }, + { + :title => 'should set gzip_proxied', + :attr => 'gzip_proxied', + :value => 'any', + :match => ' gzip_proxied any;', + }, + { + :title => 'should set gzip_types (array)', + :attr => 'gzip_types', + :value => ['text/plain','text/html'], + :match => ' gzip_types text/plain text/html;', + }, + { + :title => 'should set gzip_types (string)', + :attr => 'gzip_types', + :value => ['text/plain'], + :match => ' gzip_types text/plain;', + }, + { + :title => 'should set gzip_vary', + :attr => 'gzip_vary', + :value => 'on', + :match => ' gzip_vary on;', + }, { :title => 'should set proxy_cache_path', :attr => 'proxy_cache_path', diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index 79fa31358..903c8b2f6 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -60,10 +60,23 @@ http { tcp_nodelay <%= @http_tcp_nodelay %>; <% if @gzip == 'on' -%> - gzip on; - gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - + gzip on; +<% if @gzip_buffers -%> + gzip_buffers <%= @gzip_buffers %>; +<% end -%> + gzip_comp_level <%= @gzip_comp_level %>; +<% if @gzip_disable -%> + gzip_disable <%= @gzip_disable %>; +<% end -%> + gzip_min_length <%= @gzip_min_length %>; + gzip_http_version <%= @gzip_http_version %>; +<% if @gzip_proxied -%> + gzip_proxied <%= @gzip_proxied %>; <% end -%> + gzip_types <%= @gzip_types.kind_of?(Array) ? @gzip_types.join(' ') : @gzip_types %>; + gzip_vary <%= @gzip_vary %>; +<% end -%> + <% if @client_body_temp_path -%> client_body_temp_path <%= @client_body_temp_path %>; <% end -%>