Skip to content

Commit

Permalink
Merge pull request #659 from 3flex/gzip_enhancements
Browse files Browse the repository at this point in the history
add remaining gzip directives
  • Loading branch information
3flex committed Jul 12, 2015
2 parents d1b0908 + 35577cc commit 3375223
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 4 deletions.
8 changes: 8 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
56 changes: 55 additions & 1 deletion spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,68 @@
:title => 'should set gzip',
:attr => 'gzip',
:value => 'on',
:match => ' gzip on;',
:match => ' gzip on;',
},
{
:title => 'should not set gzip',
:attr => 'gzip',
: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',
Expand Down
19 changes: 16 additions & 3 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down

0 comments on commit 3375223

Please sign in to comment.