services/cdn-shield: provide wttr.in cache

This commit is contained in:
Max Headroom 2022-07-11 21:35:02 +02:00
parent 183cd53e84
commit 2fee49cf71
2 changed files with 15 additions and 0 deletions

View file

@ -8,4 +8,7 @@ let
in in
{ {
services.nginx.virtualHosts = tools.mappers.mapSubdomains (import ./shields.nix { inherit tools; }); services.nginx.virtualHosts = tools.mappers.mapSubdomains (import ./shields.nix { inherit tools; });
services.nginx.appendHttpConfig = ''
proxy_cache_path /var/cache/nginx/wttr levels=1:2 keys_zone=wttr:10m max_size=100m inactive=30d use_temp_path=off;
'';
} }

View file

@ -4,4 +4,16 @@ with tools.vhosts;
"fonts-googleapis-com" = proxyGhost "https" "fonts.googleapis.com"; "fonts-googleapis-com" = proxyGhost "https" "fonts.googleapis.com";
"fonts-gstatic-com" = proxyGhost "https" "fonts.gstatic.com"; "fonts-gstatic-com" = proxyGhost "https" "fonts.gstatic.com";
"cdnjs-cloudflare-com" = proxyGhost "https" "cdnjs.cloudflare.com"; "cdnjs-cloudflare-com" = proxyGhost "https" "cdnjs.cloudflare.com";
"wttr-in" = let
proxy = proxyGhost "https" "wttr.in";
in proxy // {
locations."/".extraConfig = proxy.locations."/".extraConfig + ''
proxy_cache wttr;
proxy_cache_key $uri;
proxy_cache_min_uses 1;
proxy_cache_methods GET HEAD POST;
proxy_cache_valid any 10m;
proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;
'';
};
} }