Hagency does not require you to point your domain at our DNS, edge, or workspace host.
If you want users to sign in with a domain you control, such as @alice:example.com, you only need to publish the standard Matrix discovery files on that domain:
/.well-known/matrix/server/.well-known/matrix/clientYour existing website and DNS for example.com can stay exactly where they are. The only requirement is that these two HTTPS URLs exist and return the JSON generated in the dashboard.
@alice:example.com/.well-known on your domain, then connect to the homeserver URL from that JSONexample.com.Important:
server_name/.well-known #https://example.com/.well-known/matrix/serverhttps://example.com/.well-known/matrix/clientYour domain does not need any special A, CNAME, or TXT records that point to Hagency.
You can host these files from:
If you use a browser-based Matrix client such as https://app.element.io, it is not enough that the JSON opens in your browser.
The browser reads https://example.com/.well-known/matrix/client as a cross-origin request. Even if you can see the JSON in the address bar, the client can still treat autodiscovery as failed if the response headers are wrong.
At minimum, make sure:
/.well-known/matrix/client returns Content-Type: application/json/.well-known/matrix/client returns Access-Control-Allow-Origin: *Content-Type: application/json and Access-Control-Allow-Origin: * on /.well-known/matrix/server tooCommon mistakes:
https://example.com/_matrix/client/versions, so base_url should probably be https://example.com." Usually not. A more common explanation is that the client failed to read /.well-known/matrix/client, then fell back to probing example.com as if it were a direct homeserver.m.homeserver.base_url should keep using the real workspace homeserver URL generated by the dashboard, typically something like https://<workspace>.hagency.cloud. Do not rewrite base_url to your vanity domain unless you are actually serving the Matrix Client-Server API itself on example.com/_matrix/client/*.
After publishing, check the response headers directly:
curl -i https://example.com/.well-known/matrix/client curl -i https://example.com/.well-known/matrix/server
At minimum, you should see:
HTTP/1.1 200 or HTTP/2 200Content-Type: application/jsonAccess-Control-Allow-Origin: *All examples below assume:
/.well-known/matrix/client and /.well-known/matrix/server are intercepted speciallyexample.com { root * /srv/well-known @matrix_well_known path /.well-known/matrix/client /.well-known/matrix/server handle @matrix_well_known { header Content-Type application/json header Access-Control-Allow-Origin * file_server } reverse_proxy 127.0.0.1:8080 }
Place the two files at:
/srv/well-known/.well-known/matrix/client/srv/well-known/.well-known/matrix/serverserver { listen 443 ssl http2; server_name example.com; root /var/www/example.com; location = /.well-known/matrix/client { default_type application/json; add_header Access-Control-Allow-Origin * always; try_files $uri =404; } location = /.well-known/matrix/server { default_type application/json; add_header Access-Control-Allow-Origin * always; try_files $uri =404; } location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
The two files live at:
/var/www/example.com/.well-known/matrix/client/var/www/example.com/.well-known/matrix/serverWith mod_proxy, mod_proxy_http, mod_alias, and mod_headers enabled, a typical setup looks like:
<VirtualHost *:443> ServerName example.com ProxyPreserveHost On ProxyPass /.well-known/matrix/ ! Alias /.well-known/matrix/ "/var/www/example.com/.well-known/matrix/" <Directory "/var/www/example.com/.well-known/matrix"> Require all granted </Directory> <LocationMatch "^/\.well-known/matrix/(client|server)$"> ForceType application/json Header always set Access-Control-Allow-Origin "*" </LocationMatch> ProxyPass / http://127.0.0.1:8080/ ProxyPassReverse / http://127.0.0.1:8080/ </VirtualHost>
Traefik itself only routes traffic and adds headers; you still need a backend service that actually serves the two JSON files, such as a tiny static Nginx container. Here is an example label set for that static service:
labels: - "traefik.enable=true" - "traefik.http.routers.example-matrix-wellknown.rule=Host(`example.com`) && (Path(`/.well-known/matrix/client`) || Path(`/.well-known/matrix/server`))" - "traefik.http.routers.example-matrix-wellknown.priority=100" - "traefik.http.routers.example-matrix-wellknown.entrypoints=websecure" - "traefik.http.routers.example-matrix-wellknown.tls=true" - "traefik.http.routers.example-matrix-wellknown.middlewares=matrix-wellknown-headers" - "traefik.http.routers.example-matrix-wellknown.service=matrix-wellknown" - "traefik.http.middlewares.matrix-wellknown-headers.headers.customresponseheaders.Content-Type=application/json" - "traefik.http.middlewares.matrix-wellknown-headers.headers.customresponseheaders.Access-Control-Allow-Origin=*" - "traefik.http.services.matrix-wellknown.loadbalancer.server.port=80"
Your main application keeps its existing router for everything else; only /.well-known/matrix/* should hit this static service.
After publishing the files, go back to the dashboard and click Validate Published Files.
The validation checks:
/.well-known/matrix/server/.well-known/matrix/clientexample.comhttps://example.com/.well-known/matrix/server points clients back to the workspace homeserverhttps://example.com/.well-known/matrix/client points clients back to the workspace homeserver base URLIn other words, your domain only acts as the public Matrix identity and discovery entrypoint. It does not need to send normal web traffic to Hagency.
/.well-known validation failed — make sure both files are published on the exact paths and the JSON matches the current values shown in the dashboard.app.element.io still fails — check whether /.well-known/matrix/client really returns Content-Type: application/json and Access-Control-Allow-Origin: *.https://example.com/_matrix/client/versions — this usually means client-side autodiscovery failed. Do not change m.homeserver.base_url first; check CORS and Content-Type on /.well-known/matrix/client./.well-known — merge the Matrix files into the same /.well-known directory; you do not need to move the whole site.A, CNAME, or TXT records to point the domain at Hagency unless you are running some separate DNS change outside this guide.