Matrix uses SRV records and .well-known for discovering the homeserver for a domain.
https://matrix.org/docs/spec/server_server/latest#resolving-...
[0] https://matrix-org.github.io/synapse/latest/federate.html
[1] https://matrix-org.github.io/synapse/latest/delegate.html
More details here: https://matrix-org.github.io/synapse/latest/reverse_proxy.ht...
Either add an DNS SRV record to example.com pointing matrix to matrix.example.com, or server a single JSON under .well-known pointing matrix to matrix.example.com.
https://matrix.org/docs/spec/server_server/latest#resolving-...
In my instance, my root domain is served from CloudFront, so in this instance I could add an A record to a homeserver VPS and use a SRV/.well-known to point to it :)