diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 14c011b..259da08 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -105,39 +105,41 @@ gregknoppcpa.bayarea-cc.com { } encode gzip } + iitwelders.bayarea-cc.com { - encode zstd gzip + route { + # 1) Nur Text-Responses bearbeiten (HTML, CSS, JS, JSON, XML ...) + @text header Content-Type *text/* *javascript* *json* *xml* - @html header Content-Type text/html* - replace @html { - https://iitwelders.com https://iitwelders.bayarea-cc.com - //iitwelders.com //iitwelders.bayarea-cc.com - } + # 2) Replace-Handler (muss VOR dem Proxy stehen!) + replace @text { + # Substring-Rewrites + https://iitwelders.com https://iitwelders.bayarea-cc.com + //iitwelders.com //iitwelders.bayarea-cc.com - @assets header Content-Type text/css* text/javascript* application/javascript* application/json* - replace @assets { - https://iitwelders.com https://iitwelders.bayarea-cc.com - //iitwelders.com //iitwelders.bayarea-cc.com - } - - reverse_proxy https://iitwelders.com { - # Upstream nicht komprimieren lassen, sonst kann replace nicht arbeiten - header_up Accept-Encoding identity - - header_up Host iitwelders.com - transport http { - tls_server_name iitwelders.com + # Optional robuster (Regex, case-insensitive): + # re (?i)https://iitwelders\.com https://iitwelders.bayarea-cc.com + # re (?i)//iitwelders\.com //iitwelders.bayarea-cc.com } - # etwaige 30x-Location-Header auf deine Domain biegen - header_down Location https://iitwelders.bayarea-cc.com{uri} + # 3) Proxy holt unkomprimiert vom Origin (damit replace arbeiten kann) + reverse_proxy https://iitwelders.com { + header_up Host iitwelders.com + header_up Accept-Encoding identity + transport http { + tls_server_name iitwelders.com + } + # Falls 30x zurückkommt: Location auf Proxy-Domain biegen + header_down Location https://iitwelders.bayarea-cc.com{uri} + } + + # 4) Zum Schluss für den Client komprimieren + encode zstd gzip } @health path /_health respond @health "ok" 200 } - - www.fancytextstuff.com { redir https://fancytextstuff.com{uri} permanent }