57 lines
2.5 KiB
YAML
57 lines
2.5 KiB
YAML
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: imgcache-config
|
|
namespace: playmat
|
|
data:
|
|
imgcache.conf.template: |
|
|
resolver kube-dns.kube-system.svc.cluster.local ipv6=off valid=300s;
|
|
resolver_timeout 5s;
|
|
proxy_cache_path /var/cache/nginx/scryfall/images levels=1:2 keys_zone=scryfall_images:50m max_size=${IMGCACHE_IMAGES_MAX_SIZE} inactive=365d use_temp_path=off;
|
|
proxy_cache_path /var/cache/nginx/scryfall/api levels=1:2 keys_zone=scryfall_api:20m max_size=${IMGCACHE_API_MAX_SIZE} inactive=365d use_temp_path=off;
|
|
limit_req_zone $server_port zone=scryfall_upstream:1m rate=${IMGCACHE_API_RATE};
|
|
limit_req_status 429;
|
|
proxy_buffer_size 32k;
|
|
proxy_buffers 16 32k;
|
|
proxy_busy_buffers_size 64k;
|
|
server {
|
|
listen 8080;
|
|
server_name _;
|
|
location = /healthz { access_log off; default_type text/plain; return 200 "ok\n"; }
|
|
location ~ ^/img/(cards|backs)/ {
|
|
proxy_set_header Host $1.scryfall.io;
|
|
proxy_set_header User-Agent "PlaymatXMageImageCache/1.0 (+https://github.com/arcanite24/playmat)";
|
|
proxy_set_header Accept "*/*";
|
|
proxy_set_header Accept-Encoding "";
|
|
proxy_ssl_server_name on;
|
|
proxy_ssl_verify ${IMGCACHE_UPSTREAM_TLS_VERIFY};
|
|
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
|
proxy_cache scryfall_images;
|
|
proxy_cache_key $request_uri;
|
|
proxy_cache_valid 200 301 302 365d;
|
|
proxy_pass https://$1.scryfall.io$request_uri;
|
|
}
|
|
location = /img/api/cards/collection {
|
|
limit_except POST { deny all; }
|
|
proxy_pass https://api.scryfall.com/cards/collection;
|
|
proxy_set_header Host api.scryfall.com;
|
|
proxy_set_header User-Agent "PlaymatXMageImageCache/1.0 (+https://github.com/arcanite24/playmat)";
|
|
proxy_cache scryfall_api;
|
|
proxy_cache_methods GET HEAD POST;
|
|
proxy_cache_key "$request_method$request_uri$request_body";
|
|
proxy_cache_valid 200 24h;
|
|
}
|
|
location /img/api/ {
|
|
proxy_pass https://api.scryfall.com/;
|
|
proxy_set_header Host api.scryfall.com;
|
|
proxy_set_header User-Agent "PlaymatXMageImageCache/1.0 (+https://github.com/arcanite24/playmat)";
|
|
proxy_ssl_server_name on;
|
|
proxy_ssl_verify on;
|
|
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
|
proxy_cache scryfall_api;
|
|
proxy_cache_key $request_uri;
|
|
proxy_cache_valid 200 301 302 24h;
|
|
}
|
|
location / { return 404; }
|
|
}
|