From 3d655f11fd4d63dbdc7c7bc33dc2907911a34af1 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sun, 7 Jan 2024 11:22:38 +0100 Subject: [PATCH] Refactor matrix config in Caddyfile Grouped `.well-known/matrix` related configurations under a named matcher `@matrix` in the Caddyfile. This change encapsulates the headers and responses for matrix-specific paths, improving readability and maintainability. It aligns with best practices for Caddy configuration, making future updates to matrix-related rules more straightforward. --- Caddyfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Caddyfile b/Caddyfile index 29fdd21..9c013d1 100644 --- a/Caddyfile +++ b/Caddyfile @@ -6,15 +6,21 @@ private.coffee www.private.coffee { header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" header Access-Control-Expose-Headers "Content-Length,Content-Range" - header /.well-known/matrix/* Content-Type application/json - header /.well-known/matrix/* Access-Control-Allow-Origin * - respond /.well-known/matrix/server `{"m.server": "matrix.private.coffee:443"}` - respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://matrix.private.coffee"}}` + @matrix { + path matrix /.well-known/matrix/* + } @assets { path assets /assets/* } + handle @matrix { + header /.well-known/matrix/* Content-Type application/json + header /.well-known/matrix/* Access-Control-Allow-Origin * + respond /.well-known/matrix/server `{"m.server": "matrix.private.coffee:443"}` + respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://matrix.private.coffee"}}` + } + handle @assets { file_server root * /srv/private.coffee