Matrix is an open standard for decentralized communication which securely distributes persistent chatrooms over an open federation of servers, preventing any single points of control or failure. This guide will help you install and get started with Matrix and its reference home server, Synapse. You can install it on a mini-computer like the Raspberry Pi or on a Synology NAS to host Matrix Synapse for your family, friends or company. In this step by step guide I will show you how to install Synapse on your Synology NAS using Docker and Portainer.
Synapse v1.98.0 release.
This guide works perfectly with the latestSTEP 1
Please Support My work by Making a Donation.
STEP 2
Install Portainer using my step by step guide. If you already have Portainer installed on your Synology NAS, skip this STEP. Attention: Make sure you have installed the latest Portainer version.
STEP 3
Make sure you have a synology.me Wildcard Certificate. Follow my guide to get a Wildcard Certificate. If you already have a synology.me Wildcard certificate, skip this STEP.
STEP 4
Install Text Editor via Synology “Package Center”. (Mandatory STEP.) If you already have Text Editor installed on your Synology NAS, skip this STEP.
STEP 5
Go to Control Panel / Login Portal / Advanced Tab / click Reverse Proxy. Follow the instructions in the image below.
STEP 6
Now click the “Create” button. Follow the instructions in the image below.
STEP 7
After you click the Create button, the window below will open. Follow the instructions in the image below.
On the General area, set the Reverse Proxy Name description: type in Synapse. After that, add the following instructions:
Source:
Protocol: HTTPS
Hostname: synapse.yourname.synology.me
Port: 443
Check Enable HSTS
Destination:
Protocol: HTTP
Hostname: localhost
Port: 8450
STEP 8
On the Reverse Proxy Rules click the Custom Header tab. Click Create and then, from the drop-down menu, click WebSocket. After you click on WebSocket, two Header Names and two Values will be automatically added. Click Save. Follow the instructions in the image below.
STEP 9
Go to Control Panel / Network / Connectivity tab/ Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.
STEP 10
Go to Control Panel / Security / Advanced tab/ Check Enable HTTP Compression then click Apply. Follow the instructions in the image below.
STEP 11
Go to File Station and open the docker folder. Inside the docker folder, create one new folder and name it synapse. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.
STEP 12
Now create two new folders inside the synapse folder that you created at STEP 11 and name them data and db. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.
STEP 13
Go to Control Panel / Task Scheduler / Create / Scheduled Task / User-defined script. Follow the instructions in the image below.
STEP 14
Once you click on User-defined script, a new window will open. Follow the instructions below:
- General: In the Task field type in Synapse HomeServer. Uncheck the “Enabled” option. Select root User.
- Schedule: Select Run on the following date then select “Do not repeat“.
- Task Settings: Check “Send run details by email“, add your email then copy paste the code below in the Run command area. After that, click OK.
#!/bin/bash docker run --rm \ --user 1026:100 \ -v /volume1/docker/synapse/data:/data \ -e SYNAPSE_CONFIG_PATH=/data/homeserver.yaml \ -e SYNAPSE_SERVER_NAME=mariushosting \ -e SYNAPSE_REPORT_STATS=yes \ matrixdotorg/synapse:latest generate
Note: Before you paste the code above in the Run command area below, change the value numbers for – – user with your own UID and GID values. (Follow my step by step guide on how to do this.) 1026 is my personal UID value and 100 is my personal GID value. You have to type in your own values.
Note: Before you paste the code above in the Run command area, change the value for SYNAPSE_SERVER_NAME and add your own SYNAPSE SERVER NAME. mariushosting is an example for SYNAPSE SERVER NAME.
STEP 15
After you click OK on STEP 14 a new warning pop up window will open. Click OK.
After you click OK, type in your DSM Password then click Submit. Follow the instructions in the image below.
STEP 16
After you click Submit on STEP 15, select your “Synapse HomeServer” Task then click the “Run” tab. You will be asked to run Synapse HomeServer – click OK. Follow the instructions in the image below.
STEP 17
The installation process can take up to a few seconds/minutes. It will depend on your Internet speed connection.
STEP 18
Open Synology File Station, then open the data folder that you have previously created at STEP 12. As you can see, the data folder is now populated with some files. Double click on the homeserver.yaml – Follow the instructions in the image below. Note: To be able to open the homeserver.yaml file, you should have Synology Text Editor installed as per the instructions at STEP 4.
STEP 19
Copy paste the code below just after your own server_name: “yourservername”.
enable_registration: true enable_registration_without_verification: true enable_group_creation: true
STEP 20
Remove the lines below from the code in the homeserver.yaml file. Follow the instructions below.
database:
name: sqlite3
args:
database: /data/homeserver.db
STEP 21
Replace with the code below. Copy then paste it in your homeserver.yaml file. Follow the instructions in the image below
database: name: psycopg2 args: user: synapseuser password: synapsepass database: synapsedb host: synapse-db cp_min: 5 cp_max: 10
STEP 22
Click X at the top right of the page. You will be prompted to Save the changes in the homeserver.yaml file. Click Save. Follow the instructions in the image below.
STEP 23
Log into Portainer using your username and password. On the left sidebar in Portainer, click on Stacks then + Add stack. Follow the instructions in the image below.
STEP 24
In the Name field type in synapse. Follow the instructions in the image below.
services: synapse-db: image: postgres:16 container_name: Synapse-DB hostname: synapse-db security_opt: - no-new-privileges:true healthcheck: test: ["CMD", "pg_isready", "-q", "-d", "synapsedb", "-U", "synapseuser"] timeout: 45s interval: 10s retries: 10 volumes: - /volume1/docker/synapse/db:/var/lib/postgresql/data:rw environment: - POSTGRES_DB=synapsedb - POSTGRES_USER=synapseuser - POSTGRES_PASSWORD=synapsepass - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C restart: on-failure:5 synapse: image: matrixdotorg/synapse:latest container_name: Synapse hostname: synapse security_opt: - no-new-privileges:true user: 1026:100 environment: - TZ=Europe/Bucharest - SYNAPSE_CONFIG_PATH=/data/homeserver.yaml volumes: - /volume1/docker/synapse/data:/data:rw ports: - 8450:8008/tcp restart: on-failure:5 depends_on: synapse-db: condition: service_started
Note: Before you paste the code above in the Web editor area below, change the value numbers for user with your own UID and GID values. (Follow my step by step guide on how to do this.) 1026 is my personal UID value and 100 is my personal GID value. You have to type in your own values.
Note: Before you paste the code above in the Web editor area below, change the value for TZ. (Select your current Time Zone from this list.)
STEP 25
Scroll down on the page until you see a button named Deploy the stack. Click on it. Follow the instructions in the image below. The installation process can take up to a few minutes. It will depend on your Internet speed connection.
STEP 26
If everything goes right, you will see the following message at the top right of your screen: “Success Stack successfully deployed“.
STEP 27
Download the Element client for Desktop or Mobile from the blue link below.
STEP 28
Go back to STEP 1 or you will deal with karma 🙂.
STEP 29
Once the Element client is downloaded, open it then click Sign in. Follow the instructions in the image below.
STEP 30
Click Edit to edit the Homeserver. Follow the instructions in the image below.
STEP 31
On the Other homeserver area, type in your own synology.me DDNS that you have previously created at STEP 7 with https:// at the beginning, then click Continue. Follow the instructions in the image below.
STEP 32
Once you have added your own synology.me DDNS at STEP 31, Click Create account. Follow the instructions in the image below.
STEP 33
Type in your own Username and Password then click Register. Follow the instructions in the image below.
STEP 34
You’re in. Click Skip. Follow the instructions in the image below.
STEP 35
Click No on the little pop-up at the top left of the page. Follow the instructions in the image below.
STEP 36
At the top left of the page click on your name then Switch to dark mode to better view the chat. Follow the instructions in the image below.
STEP 37
Click + then New room to create your first room. Follow the instructions in the image below.
STEP 38
Type in your own details for the room, then click Create room.
Your room is now Ready!
Enjoy Matrix Synapse!
If you encounter issues by using this container, make sure to check out the Common Docker issues article.
Note: You can also install Matrix Conduit.
Note: Find out how to update the Matrix Synapse container with the latest image.
Note: How to Back Up Docker Containers on your Synology NAS.
Note: Can I run Docker on my Synology NAS? See the supported models.
Note: How to Free Disk Space on Your NAS if You Run Docker.
Note: How to Schedule Start & Stop For Docker Containers.
Note: How to Activate Email Notifications.
Note: How to Add Access Control Profile on Your NAS.
Note: How to Change Docker Containers Restart Policy.
Note: How to Use Docker Containers With VPN.
Note: Convert Docker Run Into Docker Compose.
Note: How to Clean Docker.
Note: How to Clean Docker Automatically.
Note: Best Practices When Using Docker and DDNS.
Note: Some Docker Containers Need WebSocket.
Note: Find out the Best NAS Models For Docker.
Note: Activate Gmail SMTP For Docker Containers.
This post was updated on Sunday / November 24th, 2024 at 9:05 PM