Matrix
Requisiti
- Un dominio registrato (circa 2€ l'anno con OVH) - Non è uno sponsor! Amo solo il servizio 😉
- Un PC / RaspberryPi da utilizzare come server (idealmente sempre accesso).
- Poter aprire le porte sul router (NAT / Port Forwarding) per esporre il server Matrix.
Configurazione del dominio
Questa parte è la più arbitraria perché dipende fortemente dal {domain, internet} provider scelto, quindi mi limiterò a sintetizzare per sommi capi:
- Registra un dominio di secondo livello (ES: pippo.ovh)
- Crea un dominio di terzo livello (ES: matrix.pippo.ovh)
- Punta il dominio all'IP del server Matrix. Se hai un IP dinamico, spero tu abbia scelto un buon provider (tipo OVH) che supporta il DynDNS via API.
Configurazione del server Matrix
Sulla macchina server:
- Installa docker engine seguendo le istruzioni per la tua distribuzione
- Crea una cartella
matrix:mkdir ~/matrix - Crea un file
docker-compose.yamlcon il contenuto seguente, avendo cura di impostare il tuo dominio.
services:
synapse:
image: docker.io/matrixdotorg/synapse:latest
restart: unless-stopped
# See the readme for a full documentation of the environment settings
# NOTE: You must edit homeserver.yaml to use postgres, it defaults to sqlite
environment:
- SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
- SYNAPSE_SERVER_NAME=matrix.morrolinux.ovh
- SYNAPSE_REPORT_STATS=yes
volumes:
- ./matrix-config:/data:Z
depends_on:
- db
labels:
- traefik.enable=true
- traefik.http.routers.http-synapse.entryPoints=web
- traefik.http.routers.http-synapse.rule=Host(`matrix.morrolinux.ovh`)
- traefik.http.middlewares.https_redirect.redirectscheme.scheme=https
- traefik.http.middlewares.https_redirect.redirectscheme.permanent=true
- traefik.http.routers.http-synapse.middlewares=https_redirect
- traefik.http.routers.https-synapse.entryPoints=websecure
- traefik.http.routers.https-synapse.rule=Host(`matrix.morrolinux.ovh`)
- traefik.http.routers.https-synapse.service=synapse
- traefik.http.routers.https-synapse.tls=true
- traefik.http.services.synapse.loadbalancer.server.port=8008
- traefik.http.routers.https-synapse.tls.certResolver=myresolver
traefik:
image: "traefik:v3.3"
container_name: "traefik"
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entryPoints.web.address=:80"
- "--entryPoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.httpchallenge=true"
- "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
#- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.myresolver.acme.email=info@morrolinux.it"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
- "8448:8448"
- "8008:8008"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./letsencrypt:/letsencrypt:Z"
db:
image: docker.io/postgres:15-alpine
# Change that password, of course!
environment:
- POSTGRES_USER=synapse
- POSTGRES_PASSWORD=changeme
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
volumes:
- ./schemas:/var/lib/postgresql/data:Z