add caching feature
This commit is contained in:
parent
d641af6347
commit
128fbc8258
3 changed files with 22 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ nginx:
|
||||||
vhosts: {}
|
vhosts: {}
|
||||||
streams: {}
|
streams: {}
|
||||||
maps: {}
|
maps: {}
|
||||||
|
caches: {}
|
||||||
resolver:
|
resolver:
|
||||||
- 8.8.8.8
|
- 8.8.8.8
|
||||||
- 8.8.4.4
|
- 8.8.4.4
|
||||||
|
|
@ -57,6 +58,11 @@ nginx_streams_defaults:
|
||||||
proxy_connect_timeout: "2s"
|
proxy_connect_timeout: "2s"
|
||||||
proxy_next_upstream_tries: 2
|
proxy_next_upstream_tries: 2
|
||||||
|
|
||||||
|
nginx_caches_defaults:
|
||||||
|
keys_zone_size: "10m"
|
||||||
|
cache_size: "1g"
|
||||||
|
inactive_time: "10m"
|
||||||
|
|
||||||
nginx_forcessl_vhost:
|
nginx_forcessl_vhost:
|
||||||
"https-redirect":
|
"https-redirect":
|
||||||
listen:
|
listen:
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,15 @@
|
||||||
notify:
|
notify:
|
||||||
- restart nginx
|
- restart nginx
|
||||||
|
|
||||||
|
- name: create cache directories
|
||||||
|
with_dict: "{{ nginx.caches }}"
|
||||||
|
file:
|
||||||
|
path: "/var/cache/nginx/{{ item.key }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: www-data
|
||||||
|
recurse: True
|
||||||
|
|
||||||
- name: execute ssl template
|
- name: execute ssl template
|
||||||
template:
|
template:
|
||||||
src: ssl_files.conf.j2
|
src: ssl_files.conf.j2
|
||||||
|
|
@ -58,6 +67,7 @@
|
||||||
- upstreams.conf
|
- upstreams.conf
|
||||||
- proxy.conf
|
- proxy.conf
|
||||||
- maps.conf
|
- maps.conf
|
||||||
|
- caches.conf
|
||||||
template:
|
template:
|
||||||
src: "{{ item }}.j2"
|
src: "{{ item }}.j2"
|
||||||
dest: "/etc/nginx/conf.d/{{ item }}"
|
dest: "/etc/nginx/conf.d/{{ item }}"
|
||||||
|
|
|
||||||
6
templates/caches.conf.j2
Normal file
6
templates/caches.conf.j2
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{% for cache in nginx.caches %}
|
||||||
|
{% set c = {}|combine(nginx_caches_defaults, nginx.caches[cache], recursive=True) %}
|
||||||
|
# {{ cache }}
|
||||||
|
proxy_cache_path /var/cache/nginx/{{ cache }} levels=1:2 keys_zone={{ cache }}:{{ c.keys_zone_size }} max_size={{ c.cache_size }} inactive={{ c.inactive_time }} use_temp_path=off;
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue