Skip to content

Commit

Permalink
Merge pull request voxpupuli#881 from wyardley/victorgp-master
Browse files Browse the repository at this point in the history
Add additional config variables with default values (update of voxpupuli#693)
  • Loading branch information
bastelfreak committed Sep 29, 2016
2 parents 51b3097 + a4fc35e commit 7d84059
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 35 deletions.
3 changes: 3 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
$accept_mutex_delay = '500ms',
$client_body_buffer_size = '128k',
$client_max_body_size = '10m',
$client_body_timeout = '60',
$send_timeout = '60',
$lingering_timeout = '5',
$events_use = false,
$fastcgi_cache_inactive = '20m',
$fastcgi_cache_key = false,
Expand Down
20 changes: 13 additions & 7 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,25 @@
# [*location_custom_cfg_append*] - Expects a array with extra directives
# to put after anything else inside location (used with all other types
# except custom_cfg). Used for logical structures such as if.
# [*location_cfg_append*] - Expects a hash with extra directives to put
# [*location_cfg_append*] - Expects a hash with extra directives to put
# after everything else inside location (used with all other types except
# custom_cfg)
# [*try_files*] - An array of file locations to try
# [*option*] - Reserved for future use
# [*try_files*] - An array of file locations to try
# [*option*] - Reserved for future use
# [*proxy_cache*] - This directive sets name of zone for caching.
# The same zone can be used in multiple places.
# [*proxy_cache_key*] - Override the default proxy_cache_key of
# [*proxy_cache_key*] - Override the default proxy_cache_key of
# $scheme$proxy_host$request_uri
# [*proxy_cache_use_stale*] - Override the default proxy_cache_use_stale value
# of off.
# [*proxy_cache_valid*] - This directive sets the time for caching
# different replies.
# [*proxy_method*] - If defined, overrides the HTTP method of the
# [*proxy_method*] - If defined, overrides the HTTP method of the
# request to be passed to the backend.
# [*proxy_set_body*] - If defined, sets the body passed to the backend.
# [*proxy_buffering*] - If defined, sets the proxy_buffering to the passed value.
# [*proxy_http_version*] - Sets the proxy http version
# [*proxy_set_body*] - If defined, sets the body passed to the backend.
# [*proxy_buffering*] - If defined, sets the proxy_buffering to the passed
# value.
# [*auth_basic*] - This directive includes testing name and password
# with HTTP Basic Authentication.
# [*auth_basic_user_file*] - This directive sets the htpasswd filename for
Expand Down Expand Up @@ -181,6 +183,7 @@
$proxy_cache_use_stale = undef,
$proxy_cache_valid = false,
$proxy_method = undef,
$proxy_http_version = undef,
$proxy_set_body = undef,
$proxy_buffering = undef,
$auth_basic = undef,
Expand Down Expand Up @@ -313,6 +316,9 @@
if ($proxy_method != undef) {
validate_string($proxy_method)
}
if ($proxy_http_version != undef) {
validate_string($proxy_http_version)
}
if ($proxy_set_body != undef) {
validate_string($proxy_set_body)
}
Expand Down
9 changes: 9 additions & 0 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
# different replies.
# [*proxy_method*] - If defined, overrides the HTTP method of the
# request to be passed to the backend.
# [*proxy_http_version*] - Sets the proxy http version
# [*proxy_set_body*] - If defined, sets the body passed to the backend.
# [*auth_basic*] - This directive includes testing name and
# password with HTTP Basic Authentication.
Expand Down Expand Up @@ -168,6 +169,8 @@
# [*maintenance*] - A boolean value to set a vhost in maintenance
# [*maintenance_value*] - Value to return when maintenance is on.
# Default to return 503
# [*error_pages*] - Hash: setup errors pages, hash key is the http
# code and hash value the page
# [*locations*] - Hash of vhosts ressources used by this vhost
# Actions:
#
Expand Down Expand Up @@ -231,6 +234,7 @@
$proxy_cache_use_stale = undef,
$proxy_cache_valid = false,
$proxy_method = undef,
$proxy_http_version = undef,
$proxy_set_body = undef,
$proxy_buffering = undef,
$resolver = [],
Expand Down Expand Up @@ -288,6 +292,7 @@
$mode = $::nginx::config::global_mode,
$maintenance = false,
$maintenance_value = 'return 503',
$error_pages = {},
$locations = {}
) {

Expand Down Expand Up @@ -406,6 +411,9 @@
if ($proxy_method != undef) {
validate_string($proxy_method)
}
if ($proxy_http_version != undef) {
validate_string($proxy_http_version)
}
if ($proxy_set_body != undef) {
validate_string($proxy_set_body)
}
Expand Down Expand Up @@ -622,6 +630,7 @@
proxy_cache_use_stale => $proxy_cache_use_stale,
proxy_cache_valid => $proxy_cache_valid,
proxy_method => $proxy_method,
proxy_http_version => $proxy_http_version,
proxy_set_header => $proxy_set_header,
proxy_hide_header => $proxy_hide_header,
proxy_set_body => $proxy_set_body,
Expand Down
46 changes: 20 additions & 26 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,37 @@
title: 'should set keepalive_timeout',
attr: 'keepalive_timeout',
value: '123',
match: ' keepalive_timeout 123;'
match: ' keepalive_timeout 123;'
},
{
title: 'should set keepalive_requests',
attr: 'keepalive_requests',
value: '345',
match: ' keepalive_requests 345;'
},
{
title: 'should set client_body_timeout',
attr: 'client_body_timeout',
value: '888',
match: ' client_body_timeout 888;'
},
{
title: 'should set send_timeout',
attr: 'send_timeout',
value: '963',
match: ' send_timeout 963;'
},
{
title: 'should set lingering_timeout',
attr: 'lingering_timeout',
value: '385',
match: ' lingering_timeout 385;'
},
{
title: 'should set tcp_nodelay',
attr: 'http_tcp_nodelay',
value: 'on',
match: ' tcp_nodelay on;'
match: ' tcp_nodelay on;'
},
{
title: 'should set tcp_nopush',
Expand Down Expand Up @@ -474,30 +492,6 @@
value: '/path/to/pid',
match: 'pid /path/to/pid;'
},
{
title: 'should set tcp_nodelay',
attr: 'http_tcp_nodelay',
value: 'on',
match: ' tcp_nodelay on;'
},
{
title: 'should set tcp_nopush',
attr: 'http_tcp_nopush',
value: 'on',
match: ' tcp_nopush on;'
},
{
title: 'should set keepalive_timeout',
attr: 'keepalive_timeout',
value: '123',
match: ' keepalive_timeout 123;'
},
{
title: 'should set keepalive_requests',
attr: 'keepalive_requests',
value: '345',
match: ' keepalive_requests 345;'
},
{
title: 'should set mail',
attr: 'mail',
Expand Down
6 changes: 6 additions & 0 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@
%r{^\s+proxy_hide_header\s+X-TestHeader2 value2;}
]
},
{
title: 'should set proxy_http_version',
attr: 'proxy_http_version',
value: 'value',
match: %r{\s+proxy_http_version\s+value;}
},
{
title: 'should set proxy_method',
attr: 'proxy_method',
Expand Down
12 changes: 12 additions & 0 deletions spec/defines/resource_vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@
attr: 'error_log',
value: '/path/to/error.log',
match: ' error_log /path/to/error.log;'
},
{
title: 'should set error_pages',
attr: 'error_pages',
value: { '503' => '/foo.html' },
match: ' error_page 503 /foo.html;'
}
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
Expand Down Expand Up @@ -584,6 +590,12 @@
value: '/path/to/error.log',
match: ' error_log /path/to/error.log;'
},
{
title: 'should set error_pages',
attr: 'error_pages',
value: { '503' => '/foo.html' },
match: ' error_page 503 /foo.html;'
},
{
title: 'should contain raw_prepend directives',
attr: 'raw_prepend',
Expand Down
7 changes: 5 additions & 2 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ http {
server_names_hash_bucket_size <%= @names_hash_bucket_size %>;
server_names_hash_max_size <%= @names_hash_max_size %>;

keepalive_timeout <%= @keepalive_timeout %>;
keepalive_timeout <%= @keepalive_timeout %>;
keepalive_requests <%= @keepalive_requests %>;
tcp_nodelay <%= @http_tcp_nodelay %>;
client_body_timeout <%= @client_body_timeout %>;
send_timeout <%= @send_timeout %>;
lingering_timeout <%= @lingering_timeout %>;
tcp_nodelay <%= @http_tcp_nodelay %>;

<% if @gzip == 'on' -%>
gzip on;
Expand Down
3 changes: 3 additions & 0 deletions templates/vhost/locations/proxy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
proxy_read_timeout <%= @proxy_read_timeout %>;
proxy_connect_timeout <%= @proxy_connect_timeout %>;
proxy_redirect <%= @proxy_redirect %>;
<% if @proxy_http_version -%>
proxy_http_version <%= @proxy_http_version %>;
<% end -%>
<% if @proxy_method -%>
proxy_method <%= @proxy_method %>;
<% end -%>
Expand Down
6 changes: 6 additions & 0 deletions templates/vhost/vhost_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,9 @@ server {

access_log <%= @access_log_real %>;
error_log <%= @error_log_real %>;

<% if @error_pages -%>
<%- @error_pages.keys.sort.each do |key| -%>
error_page <%= key %> <%= @error_pages[key] %>;
<%- end -%>
<% end -%>
7 changes: 7 additions & 0 deletions templates/vhost/vhost_ssl_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ server {
access_log <%= @ssl_access_log_real %>;
error_log <%= @ssl_error_log_real %>;

<% if @error_pages -%>
<%- @error_pages.keys.sort.each do |key| -%>
error_page <%= key %> <%= @error_pages[key] %>;
<%- end -%>
<% end -%>
<% if @vhost_cfg_prepend -%>
<%- @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
<%- if value.is_a?(Hash) -%>
Expand Down

0 comments on commit 7d84059

Please sign in to comment.