diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index eb00c44f8..3bcfad5b8 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -82,6 +82,8 @@ # of off. # [*proxy_cache_valid*] - This directive sets the time for caching # different replies. +# [*proxy_cache_lock*] - This directive sets the locking mechanism for pouplating cache. +# [*proxy_cache_bypass*] - Defines conditions which the response will not be cached # [*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 @@ -153,65 +155,67 @@ # } define nginx::resource::location ( - Enum['present', 'absent'] $ensure = present, - Boolean $internal = false, - String $location = $name, - String $server = undef, - Optional[String] $www_root = undef, - Optional[String] $autoindex = undef, - Array $index_files = [ + Enum['present', 'absent'] $ensure = present, + Boolean $internal = false, + String $location = $name, + String $server = undef, + Optional[String] $www_root = undef, + Optional[String] $autoindex = undef, + Array $index_files = [ 'index.html', 'index.htm', 'index.php'], - Optional[String] $proxy = undef, - Optional[String] $proxy_redirect = $::nginx::proxy_redirect, - String $proxy_read_timeout = $::nginx::proxy_read_timeout, - String $proxy_connect_timeout = $::nginx::proxy_connect_timeout, - Array $proxy_set_header = $::nginx::proxy_set_header, - Array $proxy_hide_header = $::nginx::proxy_hide_header, - Array $proxy_pass_header = $::nginx::proxy_pass_header, - Optional[String] $fastcgi = undef, - Optional[String] $fastcgi_index = undef, - Optional[Hash] $fastcgi_param = undef, - String $fastcgi_params = "${::nginx::conf_dir}/fastcgi.conf", - Optional[String] $fastcgi_script = undef, - Optional[String] $fastcgi_split_path = undef, - Optional[String] $uwsgi = undef, - Optional[Hash] $uwsgi_param = undef, - String $uwsgi_params = "${nginx::config::conf_dir}/uwsgi_params", - Optional[String] $uwsgi_read_timeout = undef, - Boolean $ssl = false, - Boolean $ssl_only = false, - Optional[String] $location_alias = undef, - Optional[Enum['any', 'all']] $location_satisfy = undef, - Optional[Array] $location_allow = undef, - Optional[Array] $location_deny = undef, - Optional[Boolean ] $stub_status = undef, - Optional[Variant[String, Array]] $raw_prepend = undef, - Optional[Variant[String, Array]] $raw_append = undef, - Optional[Hash] $location_custom_cfg = undef, - Optional[Hash] $location_cfg_prepend = undef, - Optional[Hash] $location_cfg_append = undef, - Optional[Hash] $location_custom_cfg_prepend = undef, - Optional[Hash] $location_custom_cfg_append = undef, - Optional[Array] $include = undef, - Optional[Array] $try_files = undef, - Optional[String] $proxy_cache = undef, - Optional[String] $proxy_cache_key = undef, - Optional[String] $proxy_cache_use_stale = undef, - Optional[Variant[Array, String]] $proxy_cache_valid = undef, - Optional[String] $proxy_method = undef, - Optional[String] $proxy_http_version = undef, - Optional[String] $proxy_set_body = undef, - Optional[Enum['on', 'off']] $proxy_buffering = undef, - Optional[String] $auth_basic = undef, - Optional[String] $auth_basic_user_file = undef, - Optional[String] $auth_request = undef, - Array $rewrite_rules = [], - Integer[401,599] $priority = 500, - Boolean $mp4 = false, - Boolean $flv = false, - Optional[String] $expires = undef, + Optional[String] $proxy = undef, + Optional[String] $proxy_redirect = $::nginx::proxy_redirect, + String $proxy_read_timeout = $::nginx::proxy_read_timeout, + String $proxy_connect_timeout = $::nginx::proxy_connect_timeout, + Array $proxy_set_header = $::nginx::proxy_set_header, + Array $proxy_hide_header = $::nginx::proxy_hide_header, + Array $proxy_pass_header = $::nginx::proxy_pass_header, + Optional[String] $fastcgi = undef, + Optional[String] $fastcgi_index = undef, + Optional[Hash] $fastcgi_param = undef, + String $fastcgi_params = "${::nginx::conf_dir}/fastcgi.conf", + Optional[String] $fastcgi_script = undef, + Optional[String] $fastcgi_split_path = undef, + Optional[String] $uwsgi = undef, + Optional[Hash] $uwsgi_param = undef, + String $uwsgi_params = "${nginx::config::conf_dir}/uwsgi_params", + Optional[String] $uwsgi_read_timeout = undef, + Boolean $ssl = false, + Boolean $ssl_only = false, + Optional[String] $location_alias = undef, + Optional[Enum['any', 'all']] $location_satisfy = undef, + Optional[Array] $location_allow = undef, + Optional[Array] $location_deny = undef, + Optional[Boolean ] $stub_status = undef, + Optional[Variant[String, Array]] $raw_prepend = undef, + Optional[Variant[String, Array]] $raw_append = undef, + Optional[Hash] $location_custom_cfg = undef, + Optional[Hash] $location_cfg_prepend = undef, + Optional[Hash] $location_cfg_append = undef, + Optional[Hash] $location_custom_cfg_prepend = undef, + Optional[Hash] $location_custom_cfg_append = undef, + Optional[Array] $include = undef, + Optional[Array] $try_files = undef, + Optional[String] $proxy_cache = undef, + Optional[String] $proxy_cache_key = undef, + Optional[String] $proxy_cache_use_stale = undef, + Optional[Enum['on', 'off']] $proxy_cache_lock = undef, + Optional[Variant[Array, String]] $proxy_cache_valid = undef, + Optional[Variant[Array, String]] $proxy_cache_bypass = undef, + Optional[String] $proxy_method = undef, + Optional[String] $proxy_http_version = undef, + Optional[String] $proxy_set_body = undef, + Optional[Enum['on', 'off']] $proxy_buffering = undef, + Optional[String] $auth_basic = undef, + Optional[String] $auth_basic_user_file = undef, + Optional[String] $auth_request = undef, + Array $rewrite_rules = [], + Integer[401,599] $priority = 500, + Boolean $mp4 = false, + Boolean $flv = false, + Optional[String] $expires = undef, ) { if ! defined(Class['nginx']) { diff --git a/manifests/resource/server.pp b/manifests/resource/server.pp index d8946d298..264c598f6 100644 --- a/manifests/resource/server.pp +++ b/manifests/resource/server.pp @@ -76,6 +76,8 @@ # [*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_cache_lock*] - This directive sets the locking mechanism for pouplating cache. +# [*proxy_cache_bypass*] - Defines conditions which the response will not be cached # [*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. @@ -187,6 +189,8 @@ Optional[String] $proxy_cache_key = undef, Optional[String] $proxy_cache_use_stale = undef, Optional[Variant[Array[String], String]] $proxy_cache_valid = undef, + Optional[Enum['on', 'off']] $proxy_cache_lock = undef, + Optional[Variant[Array[String], String]] $proxy_cache_bypass = undef, Optional[String] $proxy_method = undef, Optional[String] $proxy_http_version = undef, Optional[String] $proxy_set_body = undef, @@ -354,7 +358,9 @@ proxy_set_header => $proxy_set_header, proxy_hide_header => $proxy_hide_header, proxy_pass_header => $proxy_pass_header, + proxy_cache_lock => $proxy_cache_lock, proxy_set_body => $proxy_set_body, + proxy_cache_bypass => $proxy_cache_bypass, proxy_buffering => $proxy_buffering, fastcgi => $fastcgi, fastcgi_index => $fastcgi_index, diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index 22bab3c4b..bae008092 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -747,6 +747,36 @@ value: 'value', match: %r{^\s+proxy_cache_use_stale\s+value;} }, + { + title: 'should set proxy_cache_bypass with a string', + attr: 'proxy_cache_bypass', + value: '$pragma', + match: %r{^\s+proxy_cache_bypass\s+\$pragma;} + }, + { + title: 'should set proxy_cache_bypass with an array', + attr: 'proxy_cache_bypass', + value: [ + '$pragma', + '$cookie' + ], + match: [ + %r{^\s+proxy_cache_bypass\s+\$pragma;}, + %r{^\s+proxy_cache_bypass\s+\$cookie;} + ] + }, + { + title: 'should set proxy_cache_lock with a string', + attr: 'proxy_cache_lock', + value: 'on', + match: %r{^\s+proxy_cache_lock\s+on;} + }, + { + title: 'should set proxy_cache_lock with a string', + attr: 'proxy_cache_lock', + value: 'off', + match: %r{^\s+proxy_cache_lock\s+off;} + }, { title: 'should set proxy_pass', attr: 'proxy', diff --git a/templates/server/locations/proxy.erb b/templates/server/locations/proxy.erb index 36d806550..ec74e4cc5 100644 --- a/templates/server/locations/proxy.erb +++ b/templates/server/locations/proxy.erb @@ -35,7 +35,7 @@ <% if @proxy_cache -%> proxy_cache <%= @proxy_cache %>; <% end -%> -<% if @proxy_cache_valid && Array(@proxy_cache_valid).size > 0 -%> +<% if @proxy_cache_valid -%> <%- Array(@proxy_cache_valid).each do |line| -%> proxy_cache_valid <%= line %>; <%- end -%> @@ -46,4 +46,12 @@ <% if @proxy_cache_key -%> proxy_cache_key <%= @proxy_cache_key %>; <% end -%> +<% if @proxy_cache_bypass -%> + <%- Array(@proxy_cache_bypass).each do |line| -%> + proxy_cache_bypass <%= line %>; + <% end -%> +<% end -%> +<% if @proxy_cache_lock -%> + proxy_cache_lock <%= @proxy_cache_lock %>; +<% end -%> <% end -%>