From 35861f32fcf02f0403a0afd369771cca3364f7cd Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Fri, 11 Apr 2014 19:43:54 +0400 Subject: [PATCH 1/7] Added location_allow & location_deny to fastcgi location --- templates/vhost/vhost_location_fastcgi.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/vhost/vhost_location_fastcgi.erb b/templates/vhost/vhost_location_fastcgi.erb index 05d15fbf2..9f9b2105b 100644 --- a/templates/vhost/vhost_location_fastcgi.erb +++ b/templates/vhost/vhost_location_fastcgi.erb @@ -5,6 +5,12 @@ <% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |value| -%> <%= value %> <% end -%><% end -%> +<% if @location_allow -%><% location_allow.each do |allow_rule| -%> + allow <%= allow_rule %>; +<% end -%><% end -%> +<% if @location_deny -%><% @location_deny.each do |deny_rule| -%> + deny <%= deny_rule %>; +<% end -%><% end -%> <% if defined? @www_root -%> root <%= @www_root %>; <% end -%> From 96e2a08442a061507f54a576d96c9d90d80dd05f Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Fri, 11 Apr 2014 19:47:19 +0400 Subject: [PATCH 2/7] Fixed cert name sanitized --- manifests/resource/vhost.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index 457d40ba7..fe0fdc970 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -449,7 +449,7 @@ } #Generate ssl key/cert with provided file-locations - $cert = regsubst($name,' ','_') + $cert = regsubst($name,' ','_', 'G') # Check if the file has been defined before creating the file to # avoid the error when using wildcard cert on the multiple vhosts From eca0e86ae980f66f2f6501ce25c5fabd49a758e7 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Fri, 11 Apr 2014 19:55:16 +0400 Subject: [PATCH 3/7] Added options to vhost: format_log location_custom_cfg_prepend location_custom_cfg_append --- manifests/resource/vhost.pp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index fe0fdc970..d66578957 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -162,6 +162,8 @@ $location_custom_cfg = undef, $location_cfg_prepend = undef, $location_cfg_append = undef, + $location_custom_cfg_prepend = undef, + $location_custom_cfg_append = undef, $try_files = undef, $auth_basic = undef, $auth_basic_user_file = undef, @@ -170,6 +172,7 @@ $include_files = undef, $access_log = undef, $error_log = undef, + $format_log = undef, $passenger_cgi_param = undef, $use_default_location = true, $rewrite_rules = [], @@ -336,13 +339,20 @@ } } + # This was a lot to add up in parameter list so add it down here # Also opted to add more logic here and keep template cleaner which # unfortunately means resorting to the $varname_real thing - $access_log_real = $access_log ? { + $access_log_tmp = $access_log ? { undef => "${nginx::params::nx_logdir}/${name_sanitized}.access.log", default => $access_log, } + + $access_log_real = $format_log ? { + undef => $access_log_tmp, + default => "${access_log_tmp} $format_log", + } + $error_log_real = $error_log ? { undef => "${nginx::params::nx_logdir}/${name_sanitized}.error.log", default => $error_log, @@ -400,6 +410,16 @@ location_cfg_append => $location_cfg_append } } + if $location_custom_cfg_prepend { + Nginx::Resource::Location["${name_sanitized}-default"] { + location_custom_cfg_prepend => $location_custom_cfg_prepend } + } + + if $location_custom_cfg_append { + Nginx::Resource::Location["${name_sanitized}-default"] { + location_custom_cfg_append => $location_custom_cfg_append } + } + if $fastcgi != undef and !defined(File['/etc/nginx/fastcgi_params']) { file { '/etc/nginx/fastcgi_params': ensure => present, From 7e62cedafef6567f7c8fb6d206e737a10c40c609 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Fri, 11 Apr 2014 20:04:24 +0400 Subject: [PATCH 4/7] Remove trailing whitespaces --- manifests/package/debian.pp | 4 ++-- manifests/resource/mailhost.pp | 2 +- manifests/resource/vhost.pp | 4 ++-- tests/vhost_ssl.pp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/package/debian.pp b/manifests/package/debian.pp index 962c86695..a5511c83b 100644 --- a/manifests/package/debian.pp +++ b/manifests/package/debian.pp @@ -19,11 +19,11 @@ $package_source = 'nginx', $package_ensure = 'present' ) { - + if $caller_module_name != $module_name { warning("${name} is deprecated as a public API of the ${module_name} module and should no longer be directly included in the manifest.") } - + $distro = downcase($::operatingsystem) package { $package_name: diff --git a/manifests/resource/mailhost.pp b/manifests/resource/mailhost.pp index c2af3df4f..ad49ad282 100644 --- a/manifests/resource/mailhost.pp +++ b/manifests/resource/mailhost.pp @@ -64,7 +64,7 @@ group => 'root', mode => '0644', } - + if !is_integer($listen_port) { fail('$listen_port must be an integer.') } diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index d66578957..a07fd3464 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -45,7 +45,7 @@ # for SSL Support. This is not generated by this module. # [*ssl_dhparam*] - This directive specifies a file containing # Diffie-Hellman key agreement protocol cryptographic parameters, in PEM -# format, utilized for exchanging session keys between server and client. +# format, utilized for exchanging session keys between server and client. # [*ssl_key*] - Pre-generated SSL Key file to reference for SSL # Support. This is not generated by this module. # [*ssl_port*] - Default IP Port for NGINX to listen with this SSL @@ -351,7 +351,7 @@ $access_log_real = $format_log ? { undef => $access_log_tmp, default => "${access_log_tmp} $format_log", - } + } $error_log_real = $error_log ? { undef => "${nginx::params::nx_logdir}/${name_sanitized}.error.log", diff --git a/tests/vhost_ssl.pp b/tests/vhost_ssl.pp index f11c96773..0eff758d2 100644 --- a/tests/vhost_ssl.pp +++ b/tests/vhost_ssl.pp @@ -5,7 +5,7 @@ www_root => '/var/www/nginx-default', ssl => true, ssl_cert => 'puppet:///modules/sslkey/whildcard_mydomain.crt', - ssl_key => 'puppet:///modules/sslkey/whildcard_mydomain.key' + ssl_key => 'puppet:///modules/sslkey/whildcard_mydomain.key' } nginx::resource::location { 'test2.local-bob': From a6cfd8444892824c220fd1d31f71daa85de5abd2 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Fri, 11 Apr 2014 23:36:15 +0400 Subject: [PATCH 5/7] Remove duplicate location_allow & location_deny --- templates/vhost/vhost_location_fastcgi.erb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/templates/vhost/vhost_location_fastcgi.erb b/templates/vhost/vhost_location_fastcgi.erb index 43f583cf1..015e1d7d5 100644 --- a/templates/vhost/vhost_location_fastcgi.erb +++ b/templates/vhost/vhost_location_fastcgi.erb @@ -27,12 +27,6 @@ <% end -%> <% end -%> <% end -%><% end -%> -<% if @location_allow -%><% location_allow.each do |allow_rule| -%> - allow <%= allow_rule %>; -<% end -%><% end -%> -<% if @location_deny -%><% @location_deny.each do |deny_rule| -%> - deny <%= deny_rule %>; -<% end -%><% end -%> <% if defined? @www_root -%> root <%= @www_root %>; <% end -%> From f364741751efc023374744f01599da8e0f495d1e Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Sat, 12 Apr 2014 23:17:45 +0400 Subject: [PATCH 6/7] Add option proxy_connect_timeout Bug fix --- manifests/resource/vhost.pp | 2 ++ templates/vhost/vhost_location_alias.erb | 8 ++++---- templates/vhost/vhost_location_directory.erb | 8 ++++---- templates/vhost/vhost_location_fastcgi.erb | 8 ++++---- templates/vhost/vhost_location_proxy.erb | 8 ++++---- templates/vhost/vhost_location_stub_status.erb | 8 ++++---- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index 758bc5533..870513b38 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -146,6 +146,7 @@ $spdy = $nginx::params::nx_spdy, $proxy = undef, $proxy_read_timeout = $nginx::params::nx_proxy_read_timeout, + $proxy_connect_timeout = $nginx::params::nx_proxy_connect_timeout, $proxy_set_header = [], $proxy_cache = false, $proxy_cache_valid = false, @@ -391,6 +392,7 @@ location_deny => $location_deny, proxy => $proxy, proxy_read_timeout => $proxy_read_timeout, + proxy_connect_timeout => $proxy_connect_timeout, proxy_cache => $proxy_cache, proxy_cache_valid => $proxy_cache_valid, proxy_method => $proxy_method, diff --git a/templates/vhost/vhost_location_alias.erb b/templates/vhost/vhost_location_alias.erb index ccd47f8df..dfe54cc56 100644 --- a/templates/vhost/vhost_location_alias.erb +++ b/templates/vhost/vhost_location_alias.erb @@ -2,11 +2,11 @@ <% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> @@ -36,11 +36,11 @@ <% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> diff --git a/templates/vhost/vhost_location_directory.erb b/templates/vhost/vhost_location_directory.erb index c5f6f01af..a32426847 100644 --- a/templates/vhost/vhost_location_directory.erb +++ b/templates/vhost/vhost_location_directory.erb @@ -11,11 +11,11 @@ <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> @@ -54,11 +54,11 @@ <% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> diff --git a/templates/vhost/vhost_location_fastcgi.erb b/templates/vhost/vhost_location_fastcgi.erb index 015e1d7d5..ecb38b109 100644 --- a/templates/vhost/vhost_location_fastcgi.erb +++ b/templates/vhost/vhost_location_fastcgi.erb @@ -8,11 +8,11 @@ <% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> @@ -55,11 +55,11 @@ <% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> diff --git a/templates/vhost/vhost_location_proxy.erb b/templates/vhost/vhost_location_proxy.erb index fbc7765c8..b39108e75 100644 --- a/templates/vhost/vhost_location_proxy.erb +++ b/templates/vhost/vhost_location_proxy.erb @@ -8,11 +8,11 @@ <% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> @@ -61,11 +61,11 @@ <% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> diff --git a/templates/vhost/vhost_location_stub_status.erb b/templates/vhost/vhost_location_stub_status.erb index c560933e8..0405b0317 100644 --- a/templates/vhost/vhost_location_stub_status.erb +++ b/templates/vhost/vhost_location_stub_status.erb @@ -2,11 +2,11 @@ <% if @location_custom_cfg_prepend -%><% @location_custom_cfg_prepend.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> @@ -36,11 +36,11 @@ <% if @location_custom_cfg_append -%><% @location_custom_cfg_append.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %>; + <%= key %> <%= subkey %> <%= asubvalue %> <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %>; + <%= key %> <%= asubvalue %> <% end -%> <% end -%> <% end -%><% end -%> From c68fcf6be203095125e02e79603933a9d9475526 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Sun, 13 Apr 2014 13:26:25 +0400 Subject: [PATCH 7/7] * fix --- templates/vhost/vhost_location_directory.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/vhost/vhost_location_directory.erb b/templates/vhost/vhost_location_directory.erb index a32426847..3ab9be2e9 100644 --- a/templates/vhost/vhost_location_directory.erb +++ b/templates/vhost/vhost_location_directory.erb @@ -11,11 +11,11 @@ <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> <% if value.is_a?(Hash) -%><% value.each do |subkey,subvalue| -%> <% Array(subvalue).each do |asubvalue| -%> - <%= key %> <%= subkey %> <%= asubvalue %> + <%= key %> <%= subkey %> <%= asubvalue %>; <% end -%> <% end -%><% else -%> <% Array(value).each do |asubvalue| -%> - <%= key %> <%= asubvalue %> + <%= key %> <%= asubvalue %>; <% end -%> <% end -%> <% end -%><% end -%>