''' # ---------------------------------------------------- # 1. Matrix Synapse Home Server (Ports 443 & 8448) # ---------------------------------------------------- ://e3lab.org, ://example.com{ import security_headers # MATCHERS FOR DELEGATION AND BRUTE-FORCE PROTECTION # Target Matrix Federation & Client .well-known files # Essential for cross-server discovery and mobile client auto-configuration @well_known { path /.well-known/matrix/client path /.well-known/matrix/server } # HANDLERS # Serve the necessary .well-known delegation configuration strings # This prevents cross-server federation identity issues. handle @well_known { header Access-Control-Allow-Origin "*" header Content-Type "application/json" # When hitting /.well-known/matrix/client, provide Element/clients with home server info respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://e3lab.org"}}` # When hitting /.well-known/matrix/server, instruct federated servers to use port 8448 respond /.well-known/matrix/server `{"m.server":"://e3lab.org"}` } # Forward all other API and chat sync traffic to the Synapse container handle { reverse_proxy 127.0.0.1:8008 { flush_interval -1 # Disables Caddy response buffering for instantaneous message delivery } } log { output file /var/log/caddy/matrix_access.log format json } } # ---------------------------------------------------- # 2. Element Web Client (Port 443 Only) # ---------------------------------------------------- element.example.com{ import security_headers # Element handles static frontend files; no custom rate limits or buffering configurations required reverse_proxy 127.0.0.1:8080 log { output file /var/log/caddy/element_access.log format json } } '''