Skip to content

Commit 342dd2e

Browse files
authored
DevX: Add another Matrix site to docker-compose (#3511)
* remove redis, since we dont use it * update localhost TLS certificat to add *.othersite.m.localhost wildcard * allow for federation * Add services and config files for Matrix site othersite.m.localhost * add element web instance app.othersite.m.localhost * update README * exclude synapse database for othersite.m.localhost * linting
1 parent b2c594d commit 342dd2e

18 files changed

+553
-138
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dist-ssr
88
.idea/
99
public/config.json
1010
backend/synapse_tmp/*
11+
backend/synapse_tmp_othersite/*
1112
/coverage
1213
config.json
1314

@@ -28,4 +29,4 @@ yarn-error.log
2829
/test-results/
2930
/playwright-report/
3031
/blob-report/
31-
/playwright/.cache/
32+
/playwright/.cache/

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,22 @@ See also:
206206
### Backend
207207

208208
A docker compose file `dev-backend-docker-compose.yml` is provided to start the
209-
whole stack of components which is required for a local development environment:
209+
whole stack of components which is required for a local development environment
210+
including federation:
210211

211-
- Minimum Synapse Setup (servername: `synapse.m.localhost`)
212+
- Minimum Synapse Setup (servernameis: `synapse.m.localhost`, `synapse.othersite.m.localhost`)
212213
- MatrixRTC Authorization Service (Note requires Federation API and hence a TLS reverse proxy)
213-
- Minimum LiveKit SFU Setup using dev defaults for config
214-
- Redis db for completeness
214+
- Minimum LiveKit SFU setup using dev defaults for config
215215
- Minimum `localhost` Certificate Authority (CA) for Transport Layer Security (TLS)
216-
- Hostnames: `m.localhost`, `*.m.localhost`
216+
- Hostnames: `m.localhost`, `*.m.localhost`, `*.othersite.m.localhost`
217217
- Add [./backend/dev_tls_local-ca.crt](./backend/dev_tls_local-ca.crt) to your web browsers trusted
218218
certificates
219219
- Minimum TLS reverse proxy for
220-
- Synapse homeserver: `synapse.m.localhost`
221-
- MatrixRTC backend: `matrix-rtc.m.localhost`
220+
- Synapse homeserver: `synapse.m.localhost` and `synapse.othersite.m.localhost`
221+
- MatrixRTC backend: `matrix-rtc.m.localhost` and `matrix-rtc.othersite.m.localhost`
222222
- Local Element Call development `call.m.localhost` via `yarn dev --host `
223-
- Element Web `app.m.localhost`
224-
- Note certificates will expire on Thu, 03 May 2035 10:32:02 GMT
223+
- Element Web `app.m.localhost` and `app.othersite.m.localhost`
224+
- Note certificates will expire on Thr, 20 September 2035 14:27:35 CEST
225225

226226
These use a test 'secret' published in this repository, so this must be used
227227
only for local development and **_never be exposed to the public Internet._**
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
server_name: "synapse.othersite.m.localhost"
2+
public_baseurl: https://synapse.othersite.m.localhost/
3+
4+
pid_file: /data/homeserver.pid
5+
6+
listeners:
7+
- port: 18008
8+
tls: false
9+
type: http
10+
x_forwarded: true
11+
resources:
12+
- names: [client, federation, openid]
13+
compress: false
14+
15+
database:
16+
name: sqlite3
17+
args:
18+
database: /data/homeserver.db
19+
20+
media_store_path: /data/media_store
21+
signing_key_path: "/data/SERVERNAME.signing.key"
22+
23+
# Due to custom TLS certificate with domains
24+
# - m.localhost, localhost
25+
# - *.m.localhost
26+
# - *.othersite.m.localhost
27+
# we disable certificate verification to allow for federation
28+
# WARNING: DO NOT USE IN PRODUCTION!!!
29+
federation_verify_certificates: false
30+
ip_range_blacklist: []
31+
trusted_key_servers:
32+
- server_name: "synapse.m.localhost"
33+
accept_keys_insecurely: true
34+
35+
experimental_features:
36+
# MSC3266: Room summary API. Used for knocking over federation
37+
msc3266_enabled: true
38+
# MSC4222 needed for syncv2 state_after. This allow clients to
39+
# correctly track the state of the room.
40+
msc4222_enabled: true
41+
42+
# The maximum allowed duration by which sent events can be delayed, as
43+
# per MSC4140. Must be a positive value if set. Defaults to no
44+
# duration (null), which disallows sending delayed events.
45+
max_event_delay_duration: 24h
46+
47+
# Required for Element Call in Single Page Mode due to on-the-fly user registration
48+
enable_registration: true
49+
enable_registration_without_verification: true
50+
51+
report_stats: false
52+
serve_server_wellknown: true
53+
54+
# Ratelimiting settings for client actions (registration, login, messaging).
55+
#
56+
# Each ratelimiting configuration is made of two parameters:
57+
# - per_second: number of requests a client can send per second.
58+
# - burst_count: number of requests a client can send before being throttled.
59+
60+
rc_message:
61+
# This needs to match at least the heart-beat frequency plus a bit of headroom
62+
# Currently the heart-beat is every 5 seconds which translates into a rate of 0.2s
63+
per_second: 0.5
64+
burst_count: 30

backend/dev_homeserver.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@ database:
1919

2020
media_store_path: /data/media_store
2121
signing_key_path: "/data/SERVERNAME.signing.key"
22+
23+
# Due to custom TLS certificate with domains
24+
# - m.localhost, localhost
25+
# - *.m.localhost
26+
# - *.othersite.m.localhost
27+
# we disable certificate verification to allow for federation.
28+
# WARNING: DO NOT USE IN PRODUCTION!!!
29+
federation_verify_certificates: false
30+
ip_range_blacklist: []
2231
trusted_key_servers:
23-
- server_name: "matrix.org"
32+
- server_name: "synapse.othersite.m.localhost"
33+
accept_keys_insecurely: true
2434

2535
experimental_features:
2636
# MSC3266: Room summary API. Used for knocking over federation
@@ -34,6 +44,13 @@ experimental_features:
3444
# duration (null), which disallows sending delayed events.
3545
max_event_delay_duration: 24h
3646

47+
# Required for Element Call in Single Page Mode due to on-the-fly user registration
48+
enable_registration: true
49+
enable_registration_without_verification: true
50+
51+
report_stats: false
52+
serve_server_wellknown: true
53+
3754
# Ratelimiting settings for client actions (registration, login, messaging).
3855
#
3956
# Each ratelimiting configuration is made of two parameters:
@@ -45,10 +62,3 @@ rc_message:
4562
# Currently the heart-beat is every 5 seconds which translates into a rate of 0.2s
4663
per_second: 0.5
4764
burst_count: 30
48-
49-
# Required for Element Call in Single Page Mode due to on-the-fly user registration
50-
enable_registration: true
51-
enable_registration_without_verification: true
52-
53-
report_stats: false
54-
serve_server_wellknown: true

backend/dev_livekit-othersite.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
port: 17880
2+
bind_addresses:
3+
- "0.0.0.0"
4+
rtc:
5+
tcp_port: 17881
6+
port_range_start: 50300
7+
port_range_end: 50400
8+
use_external_ip: false
9+
turn:
10+
enabled: false
11+
domain: localhost
12+
cert_file: ""
13+
key_file: ""
14+
tls_port: 5349
15+
udp_port: 443
16+
external_tls: true
17+
keys:
18+
devkey: secret
19+
room:
20+
auto_create: false

backend/dev_livekit.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ rtc:
66
port_range_start: 50100
77
port_range_end: 50200
88
use_external_ip: false
9-
#redis:
10-
# address: redis:6379
11-
# username: ""
12-
# password: ""
13-
# db: 0
149
turn:
1510
enabled: false
1611
domain: localhost

backend/dev_nginx.conf

Lines changed: 127 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Synapse reverse proxy including .well-known/matrix/client
2+
# domain synapse.m.localhost
23
server {
34
listen 80;
45
listen [::]:80;
@@ -26,21 +27,61 @@ server {
2627
# This is also required for development environment.
2728
# Reason: the lk-jwt-service uses the federation API for the openid token
2829
# verification, which requires TLS
29-
location / {
30-
proxy_pass "http://homeserver:8008";
30+
location ~ ^(/_matrix|/_synapse/client) {
31+
proxy_pass "http://homeserver:8008";
3132
proxy_http_version 1.1;
32-
proxy_set_header Upgrade $http_upgrade;
33-
proxy_set_header Connection "upgrade";
34-
proxy_set_header Host $host;
3533
proxy_set_header X-Forwarded-For $remote_addr;
3634
proxy_set_header X-Forwarded-Proto $scheme;
35+
proxy_set_header Host $host;
36+
}
37+
38+
error_page 500 502 503 504 /50x.html;
39+
40+
}
41+
42+
# Synapse reverse proxy including .well-known/matrix/client
43+
# domain synapse.othersite.m.localhost
44+
server {
45+
listen 80;
46+
listen [::]:80;
47+
listen 443 ssl;
48+
listen 8448 ssl;
49+
listen [::]:443 ssl;
50+
listen [::]:8448 ssl;
51+
server_name synapse.othersite.m.localhost;
52+
ssl_certificate /root/ssl/cert.pem;
53+
ssl_certificate_key /root/ssl/key.pem;
54+
55+
# well-known config adding rtc_foci backend
56+
# Note well-known is currently not effective due to:
57+
# https://spec.matrix.org/v1.12/client-server-api/#well-known-uri the spec
58+
# says it must be at https://$server_name/... (implied port 443) Hence, we
59+
# currently rely for local development environment on deprecated config.json
60+
# setting for livekit_service_url
61+
location /.well-known/matrix/client {
62+
add_header Access-Control-Allow-Origin *;
63+
return 200 '{"m.homeserver": {"base_url": "https://synapse.othersite.m.localhost"}, "org.matrix.msc4143.rtc_foci": [{"type": "livekit", "livekit_service_url": "https://matrix-rtc.othersite.m.localhost/livekit/jwt"}]}';
64+
default_type application/json;
65+
}
66+
67+
# Reverse proxy for Matrix Synapse Homeserver
68+
# This is also required for development environment.
69+
# Reason: the lk-jwt-service uses the federation API for the openid token
70+
# verification, which requires TLS
71+
location ~ ^(/_matrix|/_synapse/client) {
72+
proxy_pass "http://homeserver-1:18008";
73+
proxy_http_version 1.1;
74+
proxy_set_header X-Forwarded-For $remote_addr;
75+
proxy_set_header X-Forwarded-Proto $scheme;
76+
proxy_set_header Host $host;
3777
}
3878

3979
error_page 500 502 503 504 /50x.html;
4080

4181
}
4282

4383
# MatrixRTC reverse proxy
84+
# domain matrix-rtc.m.localhost
4485
# - MatrixRTC Authorization Service
4586
# - LiveKit SFU websocket signaling connection
4687
upstream jwt-auth-services {
@@ -49,12 +90,8 @@ upstream jwt-auth-services {
4990
}
5091

5192
server {
52-
listen 80;
53-
listen [::]:80;
5493
listen 443 ssl;
5594
listen [::]:443 ssl;
56-
listen 8448 ssl;
57-
listen [::]:8448 ssl;
5895
server_name matrix-rtc.m.localhost;
5996
ssl_certificate /root/ssl/cert.pem;
6097
ssl_certificate_key /root/ssl/key.pem;
@@ -96,6 +133,54 @@ server {
96133

97134
}
98135

136+
# MatrixRTC reverse proxy
137+
# domain matrix-rtc.othersite.m.localhost
138+
# - MatrixRTC Authorization Service
139+
# - LiveKit SFU websocket signaling connection
140+
server {
141+
listen 443 ssl;
142+
listen [::]:443 ssl;
143+
server_name matrix-rtc.othersite.m.localhost;
144+
ssl_certificate /root/ssl/cert.pem;
145+
ssl_certificate_key /root/ssl/key.pem;
146+
147+
http2 on;
148+
149+
150+
location ^~ /livekit/jwt/ {
151+
152+
proxy_set_header Host $host;
153+
proxy_set_header X-Real-IP $remote_addr;
154+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
155+
proxy_set_header X-Forwarded-Proto $scheme;
156+
157+
# JWT Service running at port 16080
158+
proxy_pass http://auth-service-1:16080/;
159+
160+
}
161+
162+
location ^~ /livekit/sfu/ {
163+
proxy_set_header Host $host;
164+
proxy_set_header X-Real-IP $remote_addr;
165+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
166+
proxy_set_header X-Forwarded-Proto $scheme;
167+
168+
proxy_send_timeout 120;
169+
proxy_read_timeout 120;
170+
proxy_buffering off;
171+
172+
proxy_set_header Accept-Encoding gzip;
173+
proxy_set_header Upgrade $http_upgrade;
174+
proxy_set_header Connection "upgrade";
175+
176+
# LiveKit SFU websocket connection running at port 17880
177+
proxy_pass http://livekit-sfu-1:17880/;
178+
}
179+
180+
error_page 500 502 503 504 /50x.html;
181+
182+
}
183+
99184
# Convenience reverse proxy for the call.m.localhost domain to yarn dev --host
100185
server {
101186
listen 80;
@@ -161,3 +246,36 @@ server {
161246
error_page 500 502 503 504 /50x.html;
162247

163248
}
249+
250+
# Convenience reverse proxy app.othersite.m.localhost for element web
251+
server {
252+
listen 80;
253+
listen [::]:80;
254+
server_name app.othersite.m.localhost;
255+
256+
return 301 https://$host$request_uri;
257+
}
258+
259+
server {
260+
listen 443 ssl;
261+
listen [::]:443 ssl;
262+
server_name app.othersite.m.localhost;
263+
ssl_certificate /root/ssl/cert.pem;
264+
ssl_certificate_key /root/ssl/key.pem;
265+
266+
267+
location ^~ / {
268+
269+
proxy_set_header Host $host;
270+
proxy_set_header X-Real-IP $remote_addr;
271+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
272+
proxy_set_header X-Forwarded-Proto $scheme;
273+
274+
proxy_pass http://element-web-1:18081;
275+
proxy_ssl_verify off;
276+
277+
}
278+
279+
error_page 500 502 503 504 /50x.html;
280+
281+
}

0 commit comments

Comments
 (0)