From 9d687dd5fd868f3b01d34033ce3496354654edb3 Mon Sep 17 00:00:00 2001 From: Lebedev Vadim Date: Mon, 8 Jul 2013 23:06:02 +0400 Subject: [PATCH] * Add location priority option --- manifests/resource/location.pp | 28 +++++++++++++++++----------- templates/vhost/vhost_header.erb | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index 5421dbe63..614308e1b 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -23,14 +23,18 @@ # [*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 -# [*proxy_cache*] - This directive sets name of zone for caching. -# The same zone can be used in multiple places. -# [*proxy_cache_valid*] - This directive sets the time for caching -# different replies. -# [*auth_basic*] - This directive includes testing name and password -# with HTTP Basic Authentication. -# [*auth_basic_user_file*] - This directive sets the htpasswd filename for -# the authentication realm. +# [*proxy_cache*] - This directive sets name of zone for caching. +# The same zone can be used in multiple places. +# [*proxy_cache_valid*] - This directive sets the time for caching +# different replies. +# [*auth_basic*] - This directive includes testing name and password +# with HTTP Basic Authentication. +# [*auth_basic_user_file*] - This directive sets the htpasswd filename for +# the authentication realm. +# [*priority*] - Location priority. Default: 500. User priority +# 400-499, 501-599. If the priority is higher than the default priority, +# the location will be defined after root, or before root. +# # # Actions: # @@ -85,7 +89,8 @@ $proxy_cache = false, $proxy_cache_valid = false, $auth_basic = undef, - $auth_basic_user_file = undef + $auth_basic_user_file = undef, + $priority = 500 ) { File { owner => 'root', @@ -128,7 +133,7 @@ ## Create stubs for vHost File Fragment Pattern if ($ssl_only != true) { - file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-500-${name}": + file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${priority}-${name}": ensure => $ensure_real, content => $content_real, } @@ -136,7 +141,8 @@ ## Only create SSL Specific locations if $ssl is true. if ($ssl == true) { - file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-800-${name}-ssl": + $ssl_priority = $priority + 300 + file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${ssl_priority}-${name}-ssl": ensure => $ensure_real, content => $content_real, } diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index 1a376888f..4d101712f 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -18,6 +18,6 @@ server { <% end -%> <% if @rewrite_to_https -%> if ($ssl_protocol = "") { - return 301 https://$host$request_uri ; + return 301 https://$host$request_uri; } <% end -%>