diff --git a/manifests/config.pp b/manifests/config.pp index 45c1f86..d951693 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -62,6 +62,7 @@ class nginx::config( $multi_accept = 'off', $names_hash_bucket_size = '64', $names_hash_max_size = '512', + $nginx_cfg_prepend = false, $proxy_buffers = '32 4k', $proxy_buffer_size = '8k', $proxy_cache_inactive = '20m', @@ -151,6 +152,12 @@ class nginx::config( } } + if ($nginx_cfg_prepend != false) { + if !(is_hash($nginx_cfg_prepend) or is_array($nginx_cfg_prepend)) { + fail('$nginx_cfg_prepend must be either a hash or array') + } + } + validate_string($nginx_error_log) validate_string($http_access_log) validate_string($proxy_headers_hash_bucket_size) diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index f3d97f0..fa1de06 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -11,6 +11,15 @@ pid <%= @pid %>; <% end -%> error_log <%= @nginx_error_log %>; +<% if @nginx_cfg_prepend -%> + <%- field_width = @nginx_cfg_prepend.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%> + <%- @nginx_cfg_prepend.sort_by{|k,v| k}.each do |key,value| -%> + <%- Array(value).each do |asubvalue| -%> + <%= sprintf("%-*s", field_width, key) %> <%= asubvalue %>; + <%- end -%> + <%- end -%> +<% end -%> + events { worker_connections <%= @worker_connections -%>; <%- if @multi_accept == 'on' -%>