Skip to content

Commit 7003e1f

Browse files
committed
add section about endpoint routing
1 parent ae7188c commit 7003e1f

File tree

1 file changed

+67
-10
lines changed

1 file changed

+67
-10
lines changed

docs/self-hosting.md

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ required for Element Call to work properly:
3030
sync v2 API that allows them to correctly track the state of the room. This is
3131
required by Element Call to track room state reliably.
3232

33-
If you're using [Synapse](https://github.com/element-hq/synapse/) as your homeserver, you'll need
34-
to additionally add the following config items to `homeserver.yaml` to comply with Element Call:
33+
If you're using [Synapse](https://github.com/element-hq/synapse/) as your
34+
homeserver, you'll need to additionally add the following config items to
35+
`homeserver.yaml` to comply with Element Call:
3536

3637
```yaml
3738
experimental_features:
@@ -64,35 +65,91 @@ required for each site deployment.
6465
6566
![MSC4195 compatible setup](MSC4195_setup.drawio.png)
6667
67-
As depicted above, Element Call requires a
68+
As depicted above in the `example.com` site deployment, Element Call requires a
6869
[Livekit SFU](https://github.com/livekit/livekit) alongside a
6970
[Matrix Livekit JWT auth service](https://github.com/element-hq/lk-jwt-service)
7071
to implement
7172
[MSC4195: MatrixRTC using LiveKit backend](https://github.com/hughns/matrix-spec-proposals/blob/hughns/matrixrtc-livekit/proposals/4195-matrixrtc-livekit.md).
7273

74+
#### Matrix site endpoint routing
75+
76+
In the context of MatrixRTC, we suggest using a single hostname for backend
77+
communication by implementing endpoint routing within a reverse proxy setup. For
78+
the example above, this results in:
79+
| Service | Endpoint | Example |
80+
| -------- | ------- | ------- |
81+
| [Livekit SFU](https://github.com/livekit/livekit) WebSocket signalling connection | `/livekit/sfu` | `matrix-rtc.example.com/livekit/sfu` |
82+
| [Matrix Livekit JWT auth service](https://github.com/element-hq/lk-jwt-service) | `/livekit/jwt` | `matrix-rtc.example.com/livekit/jwt` |
83+
84+
85+
Using Nginx, you can achieve this by:
86+
```jsonc
87+
server {
88+
...
89+
location ^~ /livekit/jwt/ {
90+
proxy_set_header Host $host;
91+
proxy_set_header X-Real-IP $remote_addr;
92+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
93+
proxy_set_header X-Forwarded-Proto $scheme;
94+
95+
# JWT Service running at port 8080
96+
proxy_pass http://localhost:8080/;
97+
}
98+
99+
location ^~ /livekit/sfu/ {
100+
proxy_set_header Host $host;
101+
proxy_set_header X-Real-IP $remote_addr;
102+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
103+
proxy_set_header X-Forwarded-Proto $scheme;
104+
105+
proxy_send_timeout 120;
106+
proxy_read_timeout 120;
107+
proxy_buffering off;
108+
109+
proxy_set_header Accept-Encoding gzip;
110+
proxy_set_header Upgrade $http_upgrade;
111+
proxy_set_header Connection "upgrade";
112+
113+
# LiveKit SFU websocket connection running at port 7880
114+
proxy_pass http://localhost:7880/;
115+
}
116+
}
117+
````
118+
119+
120+
#### MatrixRTC backend announcement
121+
73122
> [!IMPORTANT]
74123
> As defined in
75124
> [MSC4143](https://github.com/matrix-org/matrix-spec-proposals/pull/4143)
76-
> MatrixRTC backend must be announced to the client via your **homeserver's
77-
> `.well-known/matrix/client`**. The configuration is a list of Foci configs:
125+
> MatrixRTC backend must be announced to the client via your **Matrix site's
126+
> `.well-known/matrix/client`** file (e.g.
127+
> `example.com/.well-known/matrix/client` matching the site deployment example
128+
> from above). The configuration is a list of Foci configs:
78129

79130
```json
80131
"org.matrix.msc4143.rtc_foci": [
81132
{
82133
"type": "livekit",
83-
"livekit_service_url": "https://someurl.com"
134+
"livekit_service_url": "https://matrix-rtc.example.com"
84135
},
85-
{
136+
{
86137
"type": "livekit",
87-
"livekit_service_url": "https://livekit2.com"
138+
"livekit_service_url": "https://matrix-rtc-2.example.com"
88139
},
89140
{
90-
"type": "another_foci",
91-
"props_for_another_foci": "val"
141+
"type": "nextgen_new_foci_type",
142+
"props_for_nextgen_foci": "val"
92143
}
93144
]
94145
```
95146

147+
> [!NOTE]
148+
> Most `org.matrix.msc4143.rtc_foci` configurations will only have one entry in
149+
> the array
150+
151+
152+
96153
## Building Element Call
97154

98155
> [!NOTE]

0 commit comments

Comments
 (0)