From 2fee49cf71f2d6861b45f3cc8ab3f25eeceb6425 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 11 Jul 2022 21:35:02 +0200 Subject: [PATCH] services/cdn-shield: provide wttr.in cache --- hosts/prophet/services/cdn-shield/default.nix | 3 +++ hosts/prophet/services/cdn-shield/shields.nix | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/hosts/prophet/services/cdn-shield/default.nix b/hosts/prophet/services/cdn-shield/default.nix index b1cf7f8..576a92a 100644 --- a/hosts/prophet/services/cdn-shield/default.nix +++ b/hosts/prophet/services/cdn-shield/default.nix @@ -8,4 +8,7 @@ let in { 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; + ''; } diff --git a/hosts/prophet/services/cdn-shield/shields.nix b/hosts/prophet/services/cdn-shield/shields.nix index cb2b67e..776f59e 100644 --- a/hosts/prophet/services/cdn-shield/shields.nix +++ b/hosts/prophet/services/cdn-shield/shields.nix @@ -4,4 +4,16 @@ with tools.vhosts; "fonts-googleapis-com" = proxyGhost "https" "fonts.googleapis.com"; "fonts-gstatic-com" = proxyGhost "https" "fonts.gstatic.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; + ''; + }; }