1
0
Files
angie-conv-image/doc/examples/config-template/conf/site/http-my-cache.conf.j2
2025-06-05 11:01:19 +03:00

80 lines
1.7 KiB
Django/Jinja

{%- import 'snip/cache.j2mod' as ngx_cache -%}
{%- set my_caches = (j2cfg.my_caches or []) -%}
map $uri
$to_proxy_uri
{
~^/[^/]+/(.*)$ $1;
}
map $request_method
$to_proxy_method
{
default GET;
## already handled by "proxy_cache_convert_head on;" (default setting)
# HEAD GET;
OPTIONS OPTIONS;
}
## quirks
chunked_transfer_encoding off;
proxy_method $to_proxy_method;
proxy_ignore_client_abort on;
proxy_ignore_headers Cache-Control Expires Set-Cookie Vary X-Accel-Buffering X-Accel-Expires X-Accel-Limit-Rate;
## tuning
proxy_cache_key $to_proxy_uri$is_args$args;
proxy_cache_lock on;
proxy_cache_lock_age 20s;
proxy_cache_lock_timeout 25s;
proxy_cache_use_stale error timeout invalid_header updating http_429 http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
{%- for h in my_caches %}
{{ ngx_cache.proxy_cache_path(h.name, size='10m', levels='1:2', inactive=h.max_time) }}
{%- endfor %}
server {
listen 8888;
location / { return 204; }
location /console/ {
# allow 127.0.0.0/8;
# deny all;
auto_redirect on;
alias /usr/share/angie-console-light/html/;
index index.html;
location /console/api/
{
access_log off;
api /status/;
}
location /console/api/config/
{
access_log off;
api /config/;
}
}
{%- for h in my_caches %}
location /{{ h.name }}/ {
proxy_pass {{ h.uri }}/;
proxy_cache {{ h.name }};
expires {{ h.valid_time }};
proxy_cache_valid 200 {{ h.valid_time }};
proxy_cache_valid any 30s;
}
{%- endfor %}
}