Docker compose managed Synapse home server with Postgres and Riot.
- Synapse and Coturn: avhost/docker-matrix
- Postgres: postgres
- Element: vectorim/element-web
- Volume provisioner: hasnat/volumes-provisioner
- Docker
- docker-compose
- A reverse proxy
- Python 3 (for admin scripts)
You will need to have a reverse proxy setup. I use a variant of jwilder/nginx-proxy.
Assuming you have some base domain, domain.com, and you want the matrix client to use matrix.domain.com and Element to be at element.domain.com, you will need the following from your reverse proxy:
- Listen on 443 for matrix.domain.com and forward to the Synapse container (name: matrix-synapse) at port 8008
- Listen on 8448 for domain.com and forward to the Synapse container (name: matrix-synapse) at port 8008
- Listen on 443 for element.domain.com and forward to the Riot container (name: matrix-element) at port 80
See docs/reverse_proxy for Synapse docs on reverse proxying.
- Configure env files
- Copy
samples/env
to.env
and set desired values - Copy
samples/{postgres|synapse|element}.env
files to top level directory and set desired values
- Copy
- Configure postgres synapse user
- Copy
samples/init.sql
toconfig/init.sql
- Add postrgres synapse user password in
config/init.sql
- Copy
- Configure Riot
- Copy
samples/config.json
toconfig/config.json
- Change desired settings
- Copy
- Run
setup/generate.sh
- Configure Synapse
- Copy
config/generated/homeserver.yaml
toconfig/homeserver.yaml
- Configure
database
section - Make other desired changes (see sample)
- Copy
- Configure Coturn
- Copy
config/generated/turnserver.conf
toconfig/turnserver.conf
- Add
min-port=49152
andmax-port=49300
or desired range - Be sure to update the port ranges in
docker-compose.yml
if you change these values - Make other desired changes to
config/turnserver.conf
- Copy
- Run
setup/init.sh
- Run
docker-compose up -d
- Register your user
- Make user an admin:
docker-compose exec postgres bash
psql -U postgress
\c synapse
UPDATE users SET admin = 1 WHERE name = '@foo:bar.com'
The following are the settings I have changed from the generated homeserver config.
public_baseurl: https://matrix.domain.com/
- Keys under
Listeners
and valueport: 8008
:bind_addresses: ['0.0.0.0']
admin_contact: 'mailto:[email protected]'
- Keys under
database
:name: psycopg2
- Keys under
args
:user: synapse
password: "changethisbadpassword"
database: synapse
host: postgres
cp_min: 5
cp_max: 10
enable_registration: true
- This enables registration from your Riot client; set to
false
if you want to disable.
- This enables registration from your Riot client; set to
- Values under
registrations_require_3pid
:- email
disable_msisdn_registration: true
enable_3pid_lookup: true
- Keys under
email
:smtp_host: smtp.gmail.com
smtp_port: 587
smtp_user: "[email protected]"
smtp_pass: "gmailpassword"
require_transport_security: true
notif_from: "%(app)s Homeserver <[email protected]>"
app_name: "whatever"
enable_notifs: true
client_base_url: "https://element.domain.com"
- Keys under
push
:include_content: true
- Keys under
server_notices
:system_mxid_localpart: notices
system_mxid_display_name: "Server Notices"
room_name: "Server Notices"
adm/synapseadm
provides a convient command line wrapper around curling the Synapse admin API. This is written with Python 3.
Run adm/synapseadm --help
to see available commands.
See docs/admin_api for additional Synapse admin API.
- Synapse docs: synapse
- Generating
homeserver.yaml
: synapse/docker - Postgres settings: docs/postgres
- Federation
- Email settings: synapse/install
- Reverse proxy: docs/reverse_proxy
- TURN
- Synapse Admin API: docs/admin_api
- Matrix FAQ
- Matrix API
- Element docs: element
- Configuration: docs/config
- Key backup:
- Used for inspiration