Merge pull request #659 from 3flex/gzip_enhancements

add remaining gzip directives
This commit is contained in:
Matthew Haughton 2015-07-11 20:37:08 -04:00
commit 3375223bc5
3 changed files with 79 additions and 4 deletions

View file

@ -53,6 +53,14 @@ class nginx::config(
$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',

View file

@ -236,7 +236,7 @@ describe 'nginx::config' do
:title => 'should set gzip',
:attr => 'gzip',
:value => 'on',
:match => ' gzip on;',
:match => ' gzip on;',
},
{
:title => 'should not set gzip',
@ -244,6 +244,60 @@ describe 'nginx::config' do
: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',

View file

@ -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 -%>