diff --git a/infra/matrix/caddy/Caddyfile b/infra/matrix/caddy/Caddyfile new file mode 100644 index 00000000..800c7b92 --- /dev/null +++ b/infra/matrix/caddy/Caddyfile @@ -0,0 +1,58 @@ +# Caddyfile — Reverse proxy for Conduit Matrix homeserver +# Issue: #166 / #183 +# +# Place in /etc/caddy/Caddyfile or use with `caddy run --config Caddyfile` + +# Matrix client and federation on same domain +matrix.timmy.foundation { + # Client API (.well-known, /_matrix/client) + handle /.well-known/matrix/* { + header Content-Type application/json + respond `{" + "m.homeserver": {"base_url": "https://matrix.timmy.foundation"}, + "m.identity_server": {"base_url": "https://vector.im"} + }` 200 + } + + # Handle federation (server-to-server) on standard path + handle /_matrix/server/* { + reverse_proxy localhost:6167 + } + + # Handle client API + handle /_matrix/client/* { + reverse_proxy localhost:6167 + } + + # Handle media repository + handle /_matrix/media/* { + reverse_proxy localhost:6167 + } + + # Handle federation checks + handle /_matrix/federation/* { + reverse_proxy localhost:6167 + } + + # Handle static content (if serving Element web from same domain) + handle_path /element/* { + reverse_proxy localhost:8080 + } + + # Health check / status + respond /health "OK" 200 + + # Default — you may want to serve Element web or redirect + respond "Matrix Homeserver" 200 +} + +# Optional: Serve Element Web on separate subdomain +# element.timmy.foundation { +# reverse_proxy localhost:8080 +# } + +# Federation port (8448) — server-to-server communication +# This allows other Matrix servers to find and connect to yours +matrix.timmy.foundation:8448 { + reverse_proxy localhost:6167 +}