1
0
angie-conv-image/doc/examples/config-template/README.md

109 lines
1.9 KiB
Markdown
Raw Normal View History

2024-09-30 22:16:55 +03:00
# generating config with templates
configuration:
```nginx
{%- for h in (j2cfg.my_caches or []) %}
proxy_cache_path
/angie/my-cache/{{ h.name }}
keys_zone={{ h.name }}:20m
levels=1:2 inactive={{ h.max_time }};
{%- endfor %}
server {
listen 8888;
location / { return 204; }
{%- for h in (j2cfg.my_caches or []) %}
location /{{ h.name }}/ {
2024-10-01 09:09:35 +03:00
proxy_pass {{ h.uri }}/;
2024-09-30 22:16:55 +03:00
proxy_cache {{ h.name }};
expires {{ h.valid_time }};
proxy_cache_valid 200 {{ h.valid_time }};
proxy_cache_valid any 30s;
}
{%- endfor %}
}
```
---
site configuration (via `j2cfg/my-caches.yml`):
```yml
my_caches:
- name: proxy_apt_debian
uri: https://deb.debian.org/debian
valid_time: 180m
max_time: 1440h
- name: proxy_apt_debian_security
uri: https://deb.debian.org/debian-security
valid_time: 180m
max_time: 1440h
## and so on ...
```
---
docker-compose.yml:
```yml
version: "3.8"
services:
my-cache:
container_name: my-cache
2024-11-08 12:10:06 +03:00
image: docker.io/rockdrilla/angie-conv:v0.0.5
2024-09-30 22:16:55 +03:00
restart: always
privileged: true
stop_grace_period: 15s
network_mode: host
volumes:
- "./conf/image-entry:/image-entry:ro"
- "./conf/j2cfg:/angie/j2cfg:ro"
- "./conf/site:/angie/site:ro"
- "./cache:/angie/my-cache"
```
---
final configuration looks like this:
```nginx
proxy_cache_path
/angie/my-cache/proxy_apt_debian
keys_zone=proxy_apt_debian:20m
levels=1:2 inactive=1440h;
# ...
server {
# ...
location /proxy_apt_debian/ {
2024-10-01 09:09:35 +03:00
proxy_pass https://deb.debian.org/debian/;
2024-09-30 22:16:55 +03:00
proxy_cache proxy_apt_debian;
expires 180m;
proxy_cache_valid 200 180m;
proxy_cache_valid any 30s;
}
# ...
}
```
---
Test URI e.g. with `curl`:
```sh
curl -v http://localhost:8888/proxy_apt_debian/dists/bookworm/main/binary-all/Release
```