User Tools

This is an old revision of the document!


Matrix - Synapse

Matrix is a project to create a decentralized chat / messaging world. Probably much more than that, but i think it's the definitive and only future-proof messaging solution.

useradd -d /data/daemons/synapse -m synapse mkdir /data/synapse chown synapse:synapse /data/synapse su - synapse mkdir /deposito/synapse/data mkdir /deposito/synapse/database mkdir /deposito/synapse/bridges mkdir /deposito/synapse/bridges/telegram

docker-composer.yml

podman compose pull

Edit your /deposito/synapse/data/homeserver.yaml

docker-compose.yml
version: '3'
services:
  synapse:
    image: docker.io/matrixdotorg/synapse:latest
    restart: unless-stopped
    environment:
      - SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
    volumes:
      - /data/synapse/data:/data
    depends_on:
      - db
    ports:
      - 8008:8008/tcp
    networks:
      - synapse-net

  db:
    image: docker.io/postgres:12-alpine
    environment:
      - POSTGRES_USER=synapse
      - POSTGRES_PASSWORD=< my db password >
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
    volumes:
      - /data/synapse/database:/var/lib/postgresql/data
    networks:
      - synapse-net

networks:
  synapse-net: {}

Generate initial configuration file:

podman compose run --rm -e SYNAPSE_SERVER_NAME=chat.mydomain.com -e SYNAPSE_REPORT_STATS=yes synapse generate

Edit the config file:

homeserver.yaml
server_name: "chat.mydomain.com"
pid_file: /data/homeserver.pid
# NOTE: enable the following two lines ONLY to create users, then REMOVE them!
#enable_registration: true
#enable_registration_without_verification: true
listeners:
  - port: 8008
    tls: false
    type: http
    x_forwarded: true
    resources:
      - names: [client, federation]
        compress: false
database:
  name: psycopg2
  args:
    user: synapse
    password: < my db password >
    dbname: synapse
    host: db
    cp_min: 5
    cp_max: 10
log_config: "/data/chat.mydomain.com.log.config"
media_store_path: /data/media_store
registration_shared_secret: "<<< random secret >>>"
report_stats: true
macaroon_secret_key: "<<< random key >>>"
form_secret: "<<< random secret >>>"
signing_key_path: "/data/chat.mydomain.com.signing.key"
trusted_key_servers:
  - server_name: "matrix.org"

To create users:

podman compose run --rm --entrypoint /bin/bash synapse
/usr/local/bin/register_new_matrix_user https://chat.mydomain.com  -c /data/homeserver.yaml
chat.conf
server {
        server_name chat.mydomain.com;
        listen 8443 ssl; 
        listen 443 ssl; 

        access_log /var/log/nginx/chat.mydomain.com_access_log main;
        error_log /var/log/nginx/chat.mydomain.com_error_log info;

        location ~ ^(/_matrix|/_synapse/client) {
                # note: do not add a path (even a single /) after the port in `proxy_pass`,
                # otherwise nginx will canonicalise the URI and cause signature verification
                # errors.
                proxy_pass http://127.0.0.1:8008;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $host;

                # Nginx by default only allows file uploads up to 1M in size
                # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
                client_max_body_size 500M;

        # Synapse responses may be chunked, which is an HTTP/1.1 feature.
        proxy_http_version 1.1;
        }
        include com.mydomain/certbot.conf;
}

Telegram bridge crea app telegram https://my.telegram.org/apps prendi api_id api_hash, magari crea pure bot edit /deposito/synapse/bridges/telegramconfig.yaml - persmissione

file config

This website uses technical cookies only. No information is shared with anybody or used in any way but provide the website in your browser.

More information