Matrix & Riot.im
Self hosted federated chat system
Installation
mkdir synapse cd synapse virtualenv -p python3 ./env source ./env/bin/activate pip install --upgrade pip pip install --upgrade setuptools pip install matrix-synapse python -m synapse.app.homeserver --server-name chat.kalenpw.com --config-path homeserver.yaml --generate-config --report-stats=no
Configure
Edit homeserver.yaml:194
- port: 8008 tls: false type: http x_forwarded: true bind_addresses: ['127.0.0.1'] resources: - names: [client, federation] compress: false
Whatever address is used for bind_addresses
will need to match nginx config
Nginx Reverse Proxy
server { listen 80; listen [::]:80; server_name chat.kalenpw.com; return 301 https://$host$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; server_name chat.kalenpw.com; ssl on; ssl_certificate /etc/letsencrypt/live/chat.kalenpw.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/chat.kalenpw.com/privkey.pem; location / { proxy_pass http://127.0.0.1:8008; proxy_set_header X-Forwarded-For $remote_addr; } } server { listen 8448 ssl default_server; listen [::]:8448 ssl default_server; server_name chat.kalenpw.com; ssl on; ssl_certificate /etc/letsencrypt/live/chat.kalenpw.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/chat.kalenpw.com/privkey.pem; location / { proxy_pass http://127.0.0.1:8008; proxy_set_header X-Forwarded-For $remote_addr; } }
Postgres
sudo apt install libpq-dev pip install matrix-synapse[postgres] sudo apt install postgresql sudo su - postgres createuser --pwprompt synapse_user psql
CREATE DATABASE synapse ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER synapse_user;
homeserver.yaml
database: name: psycopg2 args: user: synapse_user password: DBPass database: synapse host: localhost cp_min: 5 cp_max: 10
Register User
register_new_matrix_user -c ~/synapse/homeserver.yaml http://127.0.0.1:8008