Skip to content

Finishing up Caddy

Now that you have your config set up, you can fill in the rest of the Caddy config.

Before we go any further, you will need to set up well-known files. To do this, I typically place them in /var/www/.well-known:

sudo mkdir -p /var/www/.well-known/matrix

Then, create the following files:

{
    "m.homeserver": {
        "base_url": "https://your-domain.example",
    }
}
{
    "m.server": "your-domain.example:443"
}
{
  "contacts": [
    {
      "matrix_id": "@your-matrix-id:your-domain.example",
      "role": "m.role.admin"
    },
    {
      "email_address": "your-email@your-domain.example",
      "role": "m.role.security"
    }
  ]
}

Then, serve them with Caddy (edit /etc/caddy/Caddyfile):

your-domain.example {
    header /.well-known/matrix/* Access-Control-Allow-Origin "*"
    header /.well-known/matrix/* Access-Control-Allow-Origin "*"
    file_server /.well-known/matrix/* {
        root * /var/www/
        # ^ This will only serve files frmo /var/www/.well-known/matrix/,
        # the path from the request is appended (and also sanitised
        # to prevent directory traversal attacks).
    }
    # Reverse proxy to the server
    reverse_proxy /_matrix/* 127.0.0.1:6167
}

Target IP

The IP address in the reverse_proxy line should be the IP address of the server running Continuwuity. If you are running Caddy on the same server, you can use 127.0.0.1. If you are running Caddy on a different server, you will need to use the Tailscale IP address of the server running Continuwuity.

Then, reload Caddy to apply the changes: caddy reload --config=/etc/caddy/Caddyfile.

Now, visit https://your-domain.example/.well-known/matrix/client in your browser. You should see the JSON file you created earlier. If you don't, check the Caddy logs for errors.

If you see the JSON file, congratulations! You are almost ready to go - other servers, and most importantly clients, will now be able to find your server and connect to it.