Commit 750557e4671f

Vincent Demeester <vincent@sbr.pm>
2026-06-04 15:02:06
feat(carthage): log request headers for echo service
Enabled log_credentials globally so Authorization headers are captured in logs. Added dedicated access log for echo.sbr.pm with full request headers in JSON format.
1 parent 67fe80a
Changed files (1)
systems
carthage
systems/carthage/extra.nix
@@ -88,7 +88,7 @@ let
 
     Request
     -------
-    {{.Req.Method}} {{.Req.URL.RequestURI}} {{.Req.Proto}}
+    {{.Req.Method}} {{placeholder "http.request.orig_uri"}} {{.Req.Proto}}
 
     Headers
     -------
@@ -730,6 +730,9 @@ in
     globalConfig = ''
       admin ${builtins.head globals.machines.carthage.net.vpn.ips}:2019
       metrics
+      servers {
+        log_credentials
+      }
     '';
 
     # Enable JSON access logging (NixOS option)
@@ -1042,7 +1045,17 @@ in
       '';
 
       # HTTP echo — echoes request headers (debug tool)
+      # Logs all headers (including Authorization) to a dedicated log file
       "echo.sbr.pm".extraConfig = ''
+        log {
+          output file /var/log/caddy/echo-requests.log {
+            roll_size 10MiB
+            roll_keep 5
+            roll_keep_for 720h
+          }
+          format json
+        }
+
         root * ${echoTemplate}
         templates {
           mime text/plain