- Synapse homeserver.yaml configuration - Element Web config.json - PostgreSQL init script for synapse DB - Nginx gateway configuration - Docker Compose for Matrix stack - README_MATRIX.md documentation
5.0 KiB
5.0 KiB
Matrix Integration for DAARION.city
Overview
Matrix забезпечує децентралізований real-time чат для DAARION.city:
- Synapse — Matrix homeserver
- Element Web — веб-клієнт
- DAARION Bridge (майбутнє) — інтеграція з City Rooms та Agents
Architecture
┌─────────────────────────────────────────────────────────┐
│ DAARION.city │
├─────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ Element Web │ │ Synapse │ │ DAARION Auth │ │
│ │ (8088) │→ │ (8008) │← │ (7020) │ │
│ └─────────────┘ └─────────────┘ └─────────────────┘ │
│ │ │ │ │
│ └───────────────┼───────────────────┘ │
│ ↓ │
│ ┌───────────┐ │
│ │ PostgreSQL│ │
│ │ (synapse)│ │
│ └───────────┘ │
└─────────────────────────────────────────────────────────┘
URLs
| Service | Internal | External |
|---|---|---|
| Synapse API | http://127.0.0.1:8008 | https://matrix.daarion.space/_matrix/ |
| Element Web | http://127.0.0.1:8088 | https://matrix.daarion.space/element/ |
| Well-known | - | https://matrix.daarion.space/.well-known/matrix/* |
Deployment Phases
Phase 1: Base Synapse (Current)
- Конфігурація homeserver.yaml
- PostgreSQL schema
- Docker Compose
- Deploy на NODE1
- SSL/DNS для matrix.daarion.space
Phase 2: Element Web
- config.json
- Deploy Element
- Nginx routing /element/
Phase 3: DAARION Auth Integration
- User provisioning при реєстрації
- SSO через DAARION JWT
- Sync user profiles
Phase 4: City Rooms Bridge
- Маппінг City Rooms → Matrix Rooms
- Agent messages → Matrix events
- Presence sync
Phase 5: Federation (Optional)
- DNS SRV records
- Federation keys
- Multi-node setup
Configuration
Environment Variables
# Required
SYNAPSE_DB_PASSWORD=your_secure_password
SYNAPSE_REGISTRATION_SECRET=your_registration_secret
TURN_SHARED_SECRET=your_turn_secret
# Optional
SYNAPSE_SERVER_NAME=daarion.space
DNS Records
matrix.daarion.space A 144.76.224.179
_matrix._tcp.daarion.space SRV 10 5 443 matrix.daarion.space
User Registration
Реєстрація через API (для інтеграції з DAARION Auth):
# Register user via admin API
curl -X POST "http://localhost:8008/_synapse/admin/v1/register" \
-H "Content-Type: application/json" \
-d '{
"nonce": "...",
"username": "user123",
"password": "...",
"admin": false
}'
Security
- Registration disabled — користувачі створюються тільки через DAARION Auth
- Admin API — обмежений доступ
- Rate limiting — налаштовано в homeserver.yaml
- E2EE — підтримується Element Web
Monitoring
Метрики доступні на порту 9000:
/_synapse/metrics— Prometheus метрики
Troubleshooting
Synapse не стартує
docker logs daarion-synapse
# Перевірити signing.key
docker exec daarion-synapse ls -la /data/
Database connection failed
# Перевірити PostgreSQL
docker exec -it dagi-postgres psql -U postgres -c "\l"
Element не підключається
- Перевірити CORS headers
- Перевірити .well-known endpoints
- Перевірити config.json base_url
Files
infra/matrix/
├── synapse/
│ ├── homeserver.yaml # Main config
│ └── log.config # Logging config
├── postgres/
│ └── init.sql # DB initialization
├── element-web/
│ └── config.json # Element config
├── gateway/
│ └── matrix.conf # Nginx config
├── docker-compose.matrix.yml
└── README_MATRIX.md