Matrix HomeServer 部屬
將 SYNAPSE_SERVER_NAME 換成你的網域,例如 SYNAPSE_SERVER_NAME=example.com
docker run -it --rm -v ./homeserver/data/:/data/ -e SYNAPSE_SERVER_NAME=你的服务端域名 -e SYNAPSE_REPORT_STATS=no matrixdotorg/synapse:latest generate
Docker compose 文件範例
1 2 3 4 5 6 7 8 9 10 11
| name: Matrix-server services: Matrix-server: container_name: Matrix-Server volumes: - ./homeserver/data/:/data/ ports: - 8008:8008 # - 8009:8009 # - 8448:8448 image: matrixdotorg/synapse:latest
|
新增一個管理員 docker exec -it Matrix-Server register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml -a -u 用户名 -p 密码
普通用戶提權 UPDATE users SET admin = true WHERE name = '@username:yourdomain.com';
Matrix Client 部屬
Config設定
nano config.json
1 2 3 4 5 6 7
| { "default_server_config": { "m.homeserver": { "base_url": "https://你的服务端域名" } } }
|
Docker compose 文件範例
1 2 3 4 5 6 7 8 9
| name: Matrix-client services: Matrix-Client: container_name: Matrix-Client ports: - 80:80 volumes: - ./config.json:/app/config.json image: vectorim/element-web
|
Matrix ServerAdmin 部屬
Config設定
nano config.json
1 2 3
| { "restrictBaseUrl": "https://你的服务端域名" }
|
Docker compose 文件範例
1 2 3 4 5 6 7 8 9 10
| name: Matrix-Admin services: Matrix-Admin: container_name: Matrix-Admin ports: - "80:80" restart: always image: awesometechnologies/synapse-admin:latest volumes: - ./config.json:/app/config.json:ro
|
Cloudflare Worker 反代 .well-known
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| const HOMESERVER_URL = "https://你的服务端域名"; const FEDERATION_SERVER = "你的服务端域名:443";
export default { async fetch(request) { const path = new URL(request.url).pathname; switch (path) { case "/.well-known/matrix/client": return new Response( JSON.stringify({ "m.homeserver": { "base_url": HOMESERVER_URL } }), { status: 200, headers: { "Access-Control-Allow-Origin": "*", "Content-Type": "application/json" } } ); case "/.well-known/matrix/server": return new Response( JSON.stringify({ "m.server": FEDERATION_SERVER }), { status: 200, headers: { "Access-Control-Allow-Origin": "*", "Content-Type": "application/json" } } ); default: return new Response("Not found", { status: 404 }); } } };
|
路由設定 你的服务端域名/.well-known/matrix/*
如果需要SSO登陸,請參考官方文黨。 https://element-hq.github.io/synapse/latest/openid.html