Matrix Homeserver Setup
Last updated
Last updated
Homeservers are key components that hosts user accounts and other data related to communication. It also facilitates communication between users on different servers by relaying messages through a network of matrix servers until it reaches the destination. Rocket.Chat listens to events happening in the homeserver and sends events relayed to other networks.
You can set up your federated Rocket.Chat workspace using any of the following methods:
: Install Synapse and Rocket.Chat using a simple setup script.
: Manually install and configure your Homeserver with Rocket.Chat.
We recommend using since this comes with some pre-configurations.
8GB of RAM
2CPU
20GB of Storage
Ubuntu 20.04
You are required to have a domain available to host your matrix homeserver.
You must be aware of this vital setting before proceeding with the installation.
Enabling ephemeral events like user typing indicator can affect the performance of your Matrix Homeserver and Rocket.Chat server for federated communication. This can be enabled by adding the following property in your Application Service configuration file:
Add and enable the following properties to make public rooms visible and searchable on other Matrix networks.
Following the automated installation enables everything by default and can be disabled by editing the generated configuration at data/matrix/synapse
.
The automated install offers a simple option to install a matrix homeserver pre-configured with Rocket.Chat.
Prerequisites
You are required to have the following on your system before installing.
A domain pointing to your server's IP.
Open your terminal in any directory of your choice.
Follow the instructions provided by the script to configure the workspace:
Server's hostname: Add your domain name.
Create A
domain records pointing to your server's IP address as requested.
synapse.<your-domain>
element.<your-domain>
traefik.<your-domain>
Enter your email address. This is used to issue an SSL certificate for your domain.
Start the container by running the following command:
Installing with the Automated setup automatically sets the values at Administration > Workspace > Settings > Federation > Matrix Bridge.
Testing the Setup
To test and ensure your Matrix setup is successful,
Download and execute the test script in the same directory where the setup was initiated.
You get a notice about the setup status.
Prerequisites
Your domain records and SSL certificates. For example, if your domain is ps-rocketchat.com,
you can create subdomains under it like matrix2.ps-rocketchat.com
.
Name the subdomains based on your preference.
All the generated DNS records pointed to your server's IP address (the same IP address).
To set up a Matrix Homeserver with Synapse manually,
Replace ps-rocketchat.com
and matrix2.ps-rocketchat.com
with your domain and subdomain respectively while following this guide.
Set up the docker network with this command:
The homeserver.yaml
configuration file is stored in the "data" directory of your current working directory. To start the Synapse Docker, use this command:
Next, set up MongoDB with this command:
To start Rocket.Chat , execute this command:
Set up Reverse Proxy
Before accessing your Rocket.Chat workspace, set up the reverse proxy following the next steps:
Create an nginx.conf
file containing forwarding rules for each domain. Create the file in the same folder where you intend to start your docker instance and paste the following contents:
Start the reverse proxy mapping the nginx.conf
and the certificate and private key for SSL by running this command:
Ensure to specify the paths to certificates if you are using relative paths. In this example, the reference location for certificates is the home folder.
Additionally, it's recommended to use the complete directory path for your nginx file, for example — /home/ubuntu/test/nginx.conf:/etc/nginx/nginx.conf:ro
Configure Rocket.Chat Matrix Bridge
See Matrix Bridge Configuration to learn more about the configurations and their definitions.
Now that your workspace is set up, navigate to Administration > Workspace > Settings > Federation > Matrix Bridge and follow these steps:
Enable Matrix Bridge.
Update the following fields with these values:
Homeserver URL: http://synapse:8008
Homeserver Domain: <your domain>
Bridge URL: http://rocketchat:3300
Be cautious not to include "https://" before your homeserver domain.
Save your changes and copy the contents of your registration file.
Creating and modifying files in the data directory may require administrative(sudo) rights.
Add the following content at the end of the homeserver.yaml
file in that same data directory and save:
Now restart the rocketchat and synapse containers with these commands:
Create a user using matrix.org as a homeserver (assuming the default whitelisted matrix.org is still set on your matrix homeserver)
Now that your federated is successful on your workspace, see the Matrix User's Guide to learn more about how to use federation.
You can decide to use your own federation tester if you're in an air-gapped environment or if you use non-standard certificates.
Now, execute this command:
To distribute the work on Rocket.Chat, you run two identical Rocket.Chat applications ( can be named rocketchat1
and rocketchat2
) that both connect to the same MongoDB. To make this setup accessible externally, you use an NGINX load balancer. This load balancer acts as a single entry point, and internally it distributes the workload between the two Rocket.Chat instances.
Before you proceed, ensure you have completed the Standalone Manual installation.
Start the second Rocket.Chat with this command:
Update the nginx.conf
file with these contents
Restart nginx with this command:
Navigate to Administration > Workspace > Settings > Federation > Matrix Bridge and update these configurations:
Homeserver Domain: <your domain>
Save your changes and copy the contents of your registration file.
Paste the contents in the data/registration.yaml
file .
Now restart the rocketchat and synapse containers with these commands:
Execute the following commands to clean up your files, reset your environment, and restart your setup:
See Federation FAQs for more troubleshooting tips.
and (> 2.3.3)
Download and execute the by running the following command. This creates a docker-compose
and a .env
file that can be edited as needed
If you want to install a specific version Rocket.Chat, navigate to the .env
file, and modify the RELEASE
variable to point to the of that version.
To set up a server, run this command to set up the Synapse environment:
Obtain SSL certificates for your domain records, if you don't have any. You can use .
Visit your domain URL in a web browser to access your Rocket.Chat workspace. Complete the and your workspace will be set up and ready to use.
Before you proceed, subscribe to any of our or on your workspace to unlock all the available federation features.
the support for on the matrix home server by creating a registration.yaml
file in the data directory that was created for synapse earlier and paste the contents of the registration file.
Now, you can proceed to .
For testing the Matrix setup, you can use the if your certificates are from a “standard” CA recognized by Linux distros, etc.
For more real-time testing, visit and complete these steps:
from your Rocket.Chat workspace with the user you just created using their matrixId (@username:matrix.org).
Check to confirm that you received the DM from your Rocket.Chat user. You can choose to respond to the message from and confirm that you can receive the response in your Rocket.Chat workspace.
Download the locally and run the test yourself from (supposing you have the CA in your keychain) using these commands:
Homeserver URL:
Bridge URL:
Now you can proceed to again.
If you had a , you also need to stop/remove the rocketchat2 docker instance.