apt update
apt install python3 docker.io nginx certbot vim
docker run -it --rm \
--mount type=volume,src=synapse-data,dst=/data \
-e SYNAPSE_SERVER_NAME=matrix.YOURDOMAIN \
-e SYNAPSE_REPORT_STATS=yes \
matrixdotorg/synapse:latest generate
Config will be located at:
/var/lib/docker/volumes/synapse-data/_data/homeserver.yaml
.Recommend you review settings.
certbot --nginx -d YOURDOMAIN -d matrix.YOURDOMAIN
Then ensure it gets automatically renewed
crontab -e
Add the line:
0 12 * * * /usr/bin/certbot renew --quiet
Remove the default server
configuration in
/etc/nginx/sites-enabled/default
and replace with
server
{
listen 443 ssl http2;
listen [::]:443 ssl http2;
# For the federation port -> remove if you don't want to enable federation
listen 8448 ssl http2 default_server;
listen [::]:8448 ssl http2 default_server;
server_name matrix.YOURDOMAIN;
location ~ ^(/_matrix|/_synapse/client)
{
# note: do not add a path (even a single /) after the port in `proxy_pass`,
# otherwise nginx will canonicalise the URI and cause signature verification
# errors.
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
# Nginx by default only allows file uploads up to 1M in size
# Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
client_max_body_size 50M;
}
}
Then restart Nginx
nginx -t && nginx -s reload
docker run -d --name synapse --mount type=volume,src=synapse-data,dst=/data \
-p 8008:8008 matrixdotorg/synapse:latest
apt install lynx
lynx http://localhost:8008
docker exec -it synapse register_new_matrix_user -u username -p password -k "registration_shared_secret from homeserver.yaml" http://localhost:8008
DNS SRV and .well-known to point DOMAIN -> matrix.DOMAIN
docker restart synapse
docker pull matrixdotorg/synapse:latest
root@localhost:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a06e8a24d1a6 1776cc2e846d "/start.py" 4 months ago Up 4 months (healthy) 8009/tcp, 0.0.0.0:8008->8008/tcp, :::8008->8008/tcp, 8448/tcp synapse
docker stop a06e8a24d1a6
docker rm a06e8a24d1a6
docker run -d --name synapse --mount type=volume,src=synapse-data,dst=/data -p 8008:8008 matrixdotorg/synapse:latest
docker images
docker image rm ed1176ae5124
SSH into the docker container
docker exec -it synapse /bin/bash
Generate a new password hash
hash_password -p newpassword123 -c /data/homeserver.yaml
Exit the container
exit
$ cd /var/lib/docker/volumes/synapse-data/_data/
$ sqlite3 homeserver.db
sqlite> SELECT name,password_hash FROM users;
sqlite> UPDATE users SET password_hash='hash_from_previous_step' WHERE name='user_name';
sqlite> .quit