From d50f580cc5c53f43a0e039e77a6099b7fee5a0bb Mon Sep 17 00:00:00 2001 From: MDLeom <2809763-curben@users.noreply.gitlab.com> Date: Thu, 12 Nov 2020 22:22:26 +0000 Subject: [PATCH] post(caddy): dedup config --- source/_posts/caddy-nixos-part-3.md | 51 ++++++++--------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/source/_posts/caddy-nixos-part-3.md b/source/_posts/caddy-nixos-part-3.md index e31c2d9..7dee492 100644 --- a/source/_posts/caddy-nixos-part-3.md +++ b/source/_posts/caddy-nixos-part-3.md @@ -141,7 +141,7 @@ in { home = cfg.dataDir; createHome = true; }; - + users.groups.caddyProxy = { members = [ "caddyProxy" ]; }; @@ -242,7 +242,7 @@ In Caddyfile, the config can be expressed as: ``` plain handle_path /img/* { rewrite * /img/gitlab.com/curben/blog/raw/site{path} - reverse_proxy https://cdn.statically.io + reverse_proxy https://cdn.statically.io } handle_path /screenshot/* { @@ -464,23 +464,19 @@ Since I also set up reverse proxy for {% post_link tor-hidden-onion-nixos 'Tor O header_up User-Agent "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" } -(oneWeekCache) { - Cache-Control "max-age=604800, public" +(reverseProxy) { + reverse_proxy https://{args.0} { + import removeHeaders + header_up Host "{args.0}" + } } (pathProxy) { - header /js/* { - import oneWeekCache - defer + @staticFiles { + path *.css *.gif *.ico *.jpg *.js *.png *.svg *.webp *.xml } - - header /css/* { - import oneWeekCache - defer - } - - header /svg/* { - import oneWeekCache + header @staticFiles { + Cache-Control "max-age=604800, public" defer } @@ -492,35 +488,16 @@ Since I also set up reverse proxy for {% post_link tor-hidden-onion-nixos 'Tor O handle_path /img/* { rewrite * /img/gitlab.com/curben/blog/raw/site{path} - reverse_proxy https://cdn.statically.io { - import removeHeaders - header_up Host cdn.statically.io - } - } - - header /img/* { - import oneWeekCache - defer + import reverseProxy cdn.statically.io } handle_path /screenshot/* { rewrite * /screenshot/curben.netlify.app{path}?mobile=true - reverse_proxy https://cdn.statically.io { - import removeHeaders - header_up Host cdn.statically.io - } + import reverseProxy cdn.statically.io } - header /screenshot/* { - import oneWeekCache - defer - } - - reverse_proxy https://curben.netlify.app { - import removeHeaders - header_up Host curben.netlify.app - } + import reverseProxy curben.netlify.app } ```