Commit 67fe80a6186c

Vincent Demeester <vincent@sbr.pm>
2026-06-04 14:48:30
feat(carthage): add HTTP echo service
Added echo.sbr.pm virtual host that echoes request headers as plain text using Caddy templates. Useful for debugging Authorization headers in OAuth flows.
1 parent 22f3bae
Changed files (1)
systems
carthage
systems/carthage/extra.nix
@@ -81,6 +81,25 @@ let
         }
   '';
 
+  # HTTP echo template - echoes request headers as plain text
+  echoTemplate = pkgs.writeTextDir "index.txt" ''
+    HTTP Echo — echo.sbr.pm
+    ========================
+
+    Request
+    -------
+    {{.Req.Method}} {{.Req.URL.RequestURI}} {{.Req.Proto}}
+
+    Headers
+    -------
+    {{range $name, $values := .Req.Header}}{{range $values}}{{$name}}: {{.}}
+    {{end}}{{end}}
+    Connection
+    ----------
+    Host: {{.Req.Host}}
+    Remote IP: {{.RemoteIP}}
+  '';
+
   # AI bot blocking snippet - enforcement via HTTP 403
   blockAIBotsSnippet = ''
     @aibots {
@@ -1022,6 +1041,16 @@ in
         ${mediaSecurityHeaders}
       '';
 
+      # HTTP echo — echoes request headers (debug tool)
+      "echo.sbr.pm".extraConfig = ''
+        root * ${echoTemplate}
+        templates {
+          mime text/plain
+        }
+        try_files /index.txt
+        file_server
+      '';
+
       # Webhook/gosmee service with SSE support
       "webhook.sbr.pm".extraConfig = ''
         reverse_proxy localhost:3333 {