Files
AgapHost/matrix/README.md
Alvis e04f9059ae Add Matrix homeserver with MatrixRTC calling support
- Synapse + PostgreSQL + coturn + LiveKit + lk-jwt-service
- Caddy entries for mtx.alogins.net, lk.alogins.net, lkjwt.alogins.net
- well-known endpoints for Matrix client/server discovery and RTC transport
- Users: admin, elizaveta, aleksandra

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-15 14:12:13 +00:00

106 lines
2.4 KiB
Markdown

# Matrix Home Server
Self-hosted Matrix homeserver running on `mtx.alogins.net`.
## Stack
| Service | Purpose |
|---------|---------|
| Synapse | Matrix homeserver |
| PostgreSQL | Synapse database |
| LiveKit | MatrixRTC media server (calls) |
| lk-jwt-service | LiveKit JWT auth for Matrix users |
| coturn | TURN/STUN server (ICE fallback) |
## Clients
- **Element X** (Android/iOS) — recommended, full call support
- **FluffyChat** — messaging only, calls not supported
Connect clients to: `https://mtx.alogins.net`
## Users
| Username | Admin |
|----------|-------|
| admin | yes |
| elizaveta | no |
| aleksandra | no |
## Managing Users
```bash
# Add user
docker exec synapse register_new_matrix_user \
-c /data/homeserver.yaml \
-u <username> -p <password> --no-admin \
http://localhost:8008
# Add admin
docker exec synapse register_new_matrix_user \
-c /data/homeserver.yaml \
-u <username> -p <password> -a \
http://localhost:8008
```
## Start / Stop
```bash
cd /home/alvis/agap_git/matrix
docker compose up -d # start all
docker compose down # stop all
docker compose restart # restart all
docker compose ps # status
docker compose logs -f # logs
```
## Caddy
Entries in `/home/alvis/agap_git/Caddyfile`:
| Domain | Purpose |
|--------|---------|
| `mtx.alogins.net` | Synapse + well-known |
| `lk.alogins.net` | LiveKit SFU |
| `lkjwt.alogins.net` | LiveKit JWT service |
Deploy Caddyfile changes:
```bash
sudo cp /home/alvis/agap_git/Caddyfile /etc/caddy/Caddyfile && sudo systemctl reload caddy
```
## Firewall Ports Required
| Port | Protocol | Service |
|------|----------|---------|
| 443 | TCP | Caddy (HTTPS) |
| 3478 | UDP+TCP | coturn TURN |
| 5349 | UDP+TCP | coturn TURNS |
| 7881 | TCP | LiveKit |
| 49152-65535 | UDP | coturn relay |
| 50100-50200 | UDP | LiveKit media |
## Data Locations
| Data | Path |
|------|------|
| Synapse config & media | `./data/synapse/` |
| PostgreSQL data | `./data/postgres/` |
| LiveKit config | `./livekit/livekit.yaml` |
| coturn config | `./coturn/turnserver.conf` |
## First-Time Setup (reference)
```bash
# Generate Synapse config
docker run --rm \
-v ./data/synapse:/data \
-e SYNAPSE_SERVER_NAME=mtx.alogins.net \
-e SYNAPSE_REPORT_STATS=no \
matrixdotorg/synapse:latest generate
# Edit database section in data/synapse/homeserver.yaml, then:
docker compose up -d
```