Solved proxy cache bugs

This commit is contained in:
2025-05-08 11:45:37 +02:00
parent d5f194b2c0
commit 1d52fcec75
6 changed files with 45 additions and 32 deletions

View File

@@ -0,0 +1,30 @@
- name: Cleanup all NGINX cache directories
become: true
ansible.builtin.file:
path: "{{ item.value }}"
state: absent
when:
- mode_cleanup | bool
- run_once_nginx_reverse_proxy is not defined
loop: "{{ nginx.directories.cache | dict2items }}"
loop_control:
label: "{{ item.key }}"
- name: Ensure all NGINX cache directories exist
become: true
ansible.builtin.file:
path: "{{ item.value }}"
state: directory
owner: "{{ nginx.user }}"
group: "{{ nginx.user }}"
mode: '0700'
when: run_once_nginx_reverse_proxy is not defined
loop: "{{ nginx.directories.cache | dict2items }}"
loop_control:
label: "{{ item.key }}"
- name: run the nginx_reverse_proxy tasks once
set_fact:
run_once_nginx_reverse_proxy: true
when: run_once_nginx_reverse_proxy is not defined

View File

@@ -42,6 +42,9 @@
{{ nginx.directories.data.values() | list }}
when: run_once_nginx is not defined
- name: "Include tasks to create cache directories"
include_tasks: cache_directories.yml
- name: create nginx config file
template:
src: nginx.conf.j2

View File

@@ -12,7 +12,14 @@ http
default_type text/html;
{# caching #}
proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:20m max_size=20g inactive=14d use_temp_path=off;
proxy_cache_path {{ nginx.directories.cache.general }} levels=1:2 keys_zone=cache:20m max_size=20g inactive=14d use_temp_path=off;
proxy_cache_path {{ nginx.directories.cache.image }} levels=1:2 keys_zone=imgcache:10m inactive=60m use_temp_path=off;
# --------------------------------------------------------------------------------
# Tweak the hash table used to store your server_name entries:
server_names_hash_bucket_size 64; # size of each bucket for server_name lookups (in bytes)
server_names_hash_max_size 512; # maximum total buckets for the server_name hash table
# --------------------------------------------------------------------------------
{# logging and debugging #}
{% if enable_debug | bool %}