Matrix Synapse-1-3
Matrix Synapse-1-3
Matrix Synapse-1-3
Matrix Synapse
Matrix is an open standard for interoperable, decentralised, real-time communication over IP. It can be
used to power Instant Messaging, VoIP and Internet of Things communication - or anywhere you need a
standard HTTP API for publishing and subscribing to data whilst tracking the conversation history.
Synapse is a reference homeserver implementation from the core development team at matrix.org, written
in Python/Twisted.
In this guide, we will show you step-by-step how to install and configure Synapse on Ubuntu 18.04. We
will configure Synapse and the Nginx web server as a reverse proxy for it and implement the HTTPS
connection between clients and the front-end Nginx web server. We will also show how to set up a
PostgreSQL database for better performance.
This guide explains one way to setup a Synapse server. There are many other correct ways to setup a
Matrix server and that is the reason why there are so many guides. Feel free to choose the guide that suits
your setup the best.
Prerequisites
Ubuntu 18.04 secured with basic security
Root privileges
A domain name for your server
What we will do
Update and Upgrade System
Install Synapse
Configure Synapse
Generate SSL certificates using Let's Encrypt
Install and configure Nginx as a reverse proxy
Install and configure Postgres instead of SQLite (optional but highly recommended, SQLite should
not be used in production)
Setup UFW Firewall
Create a new Matrix user on your server
Check federation
https://www.natrius.eu/dokuwiki/doku.php?id=digital:server:matrixsynapse 1/13
3/11/2020 Matrix Synapse [NaWiki]
Login to your Ubuntu server and add the repository key to make sure any installations and updates have
been signed by the developers and to stop any unauthorized packages from being installed on your server.
Update the repository and upgrade all packages using the apt command below.
During the installation, it will ask you about the matrix server name - type in your domain
example.com . (We will not use matrix.example.com , because we also don't use
mail.example.com for our E-Mails. This will work with well.known, SRV-records and nginx.
If you want to provide the team with information about your setup with an anonymous data report, choose
'Yes', otherwise leave it at 'No'.
When the Synapse installation is complete, start the service and enable it to launch everytime at system
boot.
https://www.natrius.eu/dokuwiki/doku.php?id=digital:server:matrixsynapse 2/13
3/11/2020 Matrix Synapse [NaWiki]
Synapse is now up and running using the default configuration on port '8008' and '8448'. Check the open
ports using netstat command.
sudo ss -plntu
Set up well.known
{
"m.server": "synapse.example.com:443"
}
Set up SRV
By setting an SRV record in your DNS provider, it is possible to tell other matrix servers where to connect
to the server, pointing them to the correct hostname and port, in this example the default port (8448) is still
used:
There is still an A record needed, pointing to the IP-addess of synapse on the subdomain
(matrix.example.com). This way others can add your user with @user:example.com instead of
@user:matrix.example.com .
Before editing the home server configuration, we need to generate the shared secret key with the following
command.
And you will get a generated key. We will disable the registration for now and then copy the key into the
homeserver configuration file. To disable the Synapse registration, uncomment the
registration_shared_secret (Delete the # and don't leave a whitespace)
https://www.natrius.eu/dokuwiki/doku.php?id=digital:server:matrixsynapse 3/13