Matrix is the chat protocol of the future. It is federated, meaning anyone can host their own server which communicates with all other servers. The matrix team have an open-source, second-generation, server called dendrite written in Go that I wanted to play with.
Here are the steps I followed to get to a working dendrite homeserver (I already had docker
and caddy
installed).
First copy the dendrite docker-compose.yaml
into a working directory.
Then, run the following commands in the directory with your docker-compose.yaml
, filling in variables like <xyz>
:
mkdir -p ./config
docker run --rm --entrypoint="/usr/bin/generate-keys" \
-v $(pwd)/config:/mnt \
matrixdotorg/dendrite-monolith:latest \
-private-key /mnt/matrix_key.pem
docker run --rm --entrypoint="/bin/sh" \
-v $(pwd)/config:/mnt \
matrixdotorg/dendrite-monolith:latest \
-c "/usr/bin/generate-config \
-dir /var/dendrite/ \
-db postgres://dendrite:<some-password>@postgres/dendrite?sslmode=disable \
-server <your-domain> > /mnt/dendrite.yaml"
Next update your config in the following way:
docker-compose.yaml
adding the postgres password to POSTGRES_PASSWORD
docker-compose.yaml
removing the 8448
port line (we will reverse proxy)config/dendrite.yaml
and filling client_api.registration_shared_secret: "aksjldalkjsdkl"
client_api.registration_disabled = true
Run:
docker-compose up -d
# Now we create our admin user
docker ps # note the dendrite container ID
docker exec -it <container-id> /usr/bin/create-account -config /etc/dendrite/dendrite.yaml -username <name> -admin
Enter your user's password when prompted, then edit config/dendrite.yaml
and unfill client_api.registration_shared_secret: ""
.
If using Caddy (the best web server), you can update your config from something like:
jenne.uk {
file_server
}
to
jenne.uk, jenne.uk:8448 {
file_server
handle /.well-known/matrix/server {
respond `{"m.server": "jenne.uk:8448"}`
}
reverse_proxy /_matrix/* localhost:8008
Check you have configured your server correctly with https://federationtester.matrix.org/
Enjoy!