Added proxy_cache_valid support (#192)

This commit is contained in:
Pritpal Sabharwal 2019-11-25 13:51:54 -08:00 committed by Alessandro Fael Garcia
parent baafb8d7de
commit cb014cdab4
4 changed files with 43 additions and 3 deletions

View File

@ -538,6 +538,11 @@ nginx_http_template:
verify_depth: 1
session_reuse: true
proxy_cache: frontend_proxy_cache
proxy_cache_valid:
- code: 200
time: 10m
- code: 301
time: 1m
proxy_temp_path:
path: /var/cache/nginx/proxy/backend/temp
proxy_cache_lock: false

View File

@ -283,6 +283,11 @@ nginx_http_template:
use_temp_path: true
proxy_temp_path:
path: /var/cache/nginx/proxy/temp
proxy_cache_valid:
- code: 200
time: 10m
- code: 301
time: 1m
proxy_cache_lock: true
proxy_cache_min_uses: 5
proxy_cache_revalidate: true
@ -350,7 +355,12 @@ nginx_http_template:
verify: false
verify_depth: 1
session_reuse: true
proxy_cache: frontend_proxy_cache
proxy_cache: backend_proxy_cache
proxy_cache_valid:
- code: 200
time: 10m
- code: 301
time: 1m
proxy_temp_path:
path: /var/cache/nginx/proxy/backend/temp
proxy_cache_lock: false

View File

@ -102,6 +102,11 @@
always: false
proxy_pass: http://frontend_servers/
proxy_cache: frontend_proxy_cache
proxy_cache_valid:
- code: 200
time: 10m
- code: 301
time: 1m
proxy_temp_path:
path: /var/cache/nginx/proxy/frontend/temp
proxy_cache_lock: false
@ -133,6 +138,8 @@
location: /backend
proxy_pass: http://backend_servers/
proxy_cache: backend_proxy_cache
proxy_cache_valid:
- time: 10m
proxy_temp_path:
path: /var/cache/nginx/proxy/backend/temp
proxy_cache_lock: true

View File

@ -26,8 +26,8 @@ upstream {{ item.value.upstreams[upstream].name }} {
{% if item.value.reverse_proxy.proxy_cache_path is defined and item.value.reverse_proxy.proxy_cache_path %}
{% for proxy_cache_path in item.value.reverse_proxy.proxy_cache_path %}
proxy_cache_path {{ proxy_cache_path.path }} keys_zone={{ proxy_cache_path.keys_zone.name }}:{{ proxy_cache_path.keys_zone.size }}
levels={{ proxy_cache_path.levels }} max_size={{ proxy_cache_path.max_size }}
inactive={{ proxy_cache_path.inactive }} use_temp_path={{ proxy_cache_path.use_temp_path | ternary("on", "off") }};
levels={{ proxy_cache_path.levels }} max_size={{ proxy_cache_path.max_size }}
inactive={{ proxy_cache_path.inactive }} use_temp_path={{ proxy_cache_path.use_temp_path | ternary("on", "off") }};
{% endfor %}
{% if item.value.reverse_proxy.proxy_cache_background_update is defined and item.value.reverse_proxy.proxy_cache_background_update%}
proxy_cache_background_update {{ item.value.reverse_proxy.proxy_cache_background_update | ternary("on", "off") }};
@ -50,6 +50,15 @@ proxy_ignore_headers {{ item.value.reverse_proxy.proxy_ignore_headers | join(" "
{% if item.value.reverse_proxy.proxy_temp_path is defined and item.value.reverse_proxy.proxy_temp_path.path %}
proxy_temp_path {{ item.value.reverse_proxy.proxy_temp_path.path }} {{ item.value.reverse_proxy.proxy_temp_path.level_1 | default("") }} {{ item.value.reverse_proxy.proxy_temp_path.level_2 | default("") }} {{ item.value.reverse_proxy.proxy_temp_path.level_3 | default("") }};
{% endif %}
{% if item.value.reverse_proxy.proxy_cache_valid is defined %}
{% for proxy_cache_valid in item.value.reverse_proxy.proxy_cache_valid %}
{% if proxy_cache_valid.code is defined %}
proxy_cache_valid {{ proxy_cache_valid.code }} {{ proxy_cache_valid.time | default("10m") }};
{% elif proxy_cache_valid.time is defined and proxy_cache_valid.code is not defined %}
proxy_cache_valid {{ proxy_cache_valid.time }};
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
{% if item.value.auth_request_http is defined %}
@ -282,6 +291,15 @@ server {
{% if item.value.reverse_proxy.locations[location].proxy_cache is defined %}
proxy_cache {{ item.value.reverse_proxy.locations[location].proxy_cache }};
{% endif %}
{% if item.value.reverse_proxy.locations[location].proxy_cache_valid is defined %}
{% for proxy_cache_valid in item.value.reverse_proxy.locations[location].proxy_cache_valid %}
{% if proxy_cache_valid.code is defined %}
proxy_cache_valid {{ proxy_cache_valid.code }} {{ proxy_cache_valid.time | default("10m") }};
{% elif proxy_cache_valid.time is defined and proxy_cache_valid.code is not defined %}
proxy_cache_valid {{ proxy_cache_valid.time }};
{% endif %}
{% endfor %}
{% endif %}
{% if item.value.reverse_proxy.locations[location].proxy_cache_background_update is defined %}
proxy_cache_background_update {{ item.value.reverse_proxy.locations[location].proxy_cache_background_update | ternary("on", "off") }};
{% endif %}