2024-07-12 17:23:19 +02:00
2024-07-12 17:23:19 +02:00
2024-09-08 11:41:18 +02:00
2024-07-12 17:23:19 +02:00
2024-09-09 20:16:31 +02:00

compose-matrix

Matrix Stack bestehend aus Matrix Server "Synapse" sowie dem Frontend "Element".

Inital setup

  1. Copy env file: cp env.sample .env
  2. Edit env file: nano .env
    1. Basedir: Full path to dir with compose file (important for swarm shares)
    2. Versionnumbers
    3. DB settings
    4. Domain! (no default)
  3. Genreate inital config for synapse:
    1. source .env
    2. docker run -it --rm --env-file .env -v ${BASEDIR:-.}/files/synapse:/data -e SYNAPSE_SERVER_NAME=$DOMAIN -e SYNAPSE_REPORT_STATS=no matrixdotorg/synapse:latest generate
      • This generate certs and basic inital config (homeserver.yml) for $DOMAIN only for first setup needed

Postgress by default not in use!
Default DB is SQLite.

  1. (optional) Set db in config: nano ${BASEDIR:-.}/files/synapse/homeserver.yaml
  2. Edit element config: nano ${BASEDIR:-.}/files/element-config.json
    1. set "default_server_name" to your domain for Synapse
    • must be manually add in first indention from json, was removed from newer versions (?)
{
    "default_server_name": "ao-it.net",
    "default_server_config": {
        "m.homeserver": {
            "base_url": "https://ao-it.net",
            "server_name": "matrix.org"
        },
...
- is need for correct display by registration (else it will display "matrix.org" even if the correct server is addressed in the backend)
  1. set "m.homeserver" => "base_url" to your domain for Element ($DOMAIN variable) - the backend server for synapse

  2. Hint: by default connection to main servers of matrix.org is enabled

  3. Hint: by default jitsi (cloud!) is uses for group videocalls

    • Hint: Jisi can be selfhost (no templace exist atm)
  4. Run stack docker compose up

howto

enable registration

  1. edit homeserver.yaml
    1. set "enable_registration" to "True"
    2. set "enable_registration_without_verification" to "True" # note: maybe not comming soon..

For disable ... well you know, set "enable_registration" to "False"

create user via cli

  1. Import .env or set $DOMAIN manually
  2. Set env $USERNAME and $USERPASS oder replace it directly
source .env
docker exec -it matrix_app_1 register_new_matrix_user -u $USERNAME -p $USERPASS -a -c /data/homeserver.yaml $DOMAIN

replace sqlite3 with postgress

  1. Edit nano ${BASEDIR:-.}/files/synapse/homeserver.yaml
  2. Remove:
database:
  name: sqlite3
  args:
    database: /data/homeserver.db
  1. Add:
database:
  name: psycopg2
  args:
    user: synapse
    password: STRONGPASSWORD
    database: synapse
    host: synapsedb
    cp_min: 5
    cp_max: 10

caddy config

synapse

  1. replace "matrix.example.com" with your servername! twice ! this "delegation" is need to NOT open port 8448 to your synapse
synapse.example.com {
    reverse_proxy /_matrix/* $IPOFDOCKERHOST:8008
    reverse_proxy /_synapse/client/* $IPOFDOCKERHOST:8008

    header {
        X-Content-Type-Options nosniff
        Referrer-Policy strict-origin-when-cross-origin
        Strict-Transport-Security "max-age=63072000; includeSubDomains;"
        Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=(), interest-cohort=()"
        X-Frame-Options SAMEORIGIN
        X-XSS-Protection 1
        X-Robots-Tag none
        -server
    }
    header /.well-known/matrix/* Content-Type application/json
    header /.well-known/matrix/* Access-Control-Allow-Origin *
    respond /.well-known/matrix/server `{"m.server": "matrix.example.com:443"}`
    respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://matrix.example.com"}}`
}

element

element.example.com {
    encode zstd gzip
    reverse_proxy $IPOFDOCKERHOST:8080

    header {
        X-Content-Type-Options nosniff
        Referrer-Policy strict-origin-when-cross-origin
        Strict-Transport-Security "max-age=63072000; includeSubDomains;"
        Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=(), interest-cohort=()"
        X-Frame-Options SAMEORIGIN
        X-XSS-Protection 1
        X-Robots-Tag none
        -server
    }
}

todo

  • setup script to auto edits
    • db in homeserver.yml
    • domain in config.json (element)

sources

Description
Matrix Stack bestehend aus Matrix Server "Synapse" sowie dem Frontend "Element".
Readme 53 KiB