Skip to content

Commit 1c65689

Browse files
committed
Refactor configuration documentation
1 parent cb750f7 commit 1c65689

File tree

2 files changed

+63
-71
lines changed

2 files changed

+63
-71
lines changed

README.md

Lines changed: 10 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
TURN server in pure Elixir.
88

99
Aims to implement:
10-
- [RFC 5766](https://datatracker.ietf.org/doc/html/rfc5766)
11-
- [RFC 6156](https://datatracker.ietf.org/doc/html/rfc6156#autoid-7)
10+
- RFC 5389: [Session Traversal Utilities for NAT (STUN)](https://datatracker.ietf.org/doc/html/rfc5389)
11+
- RFC 5766: [Traversal Using Relays around NAT (TURN): Relay Extensions to Session Traversal Utilities for NAT (STUN)](https://datatracker.ietf.org/doc/html/rfc5766)
12+
- RFC 6156: [Traversal Using Relays around NAT (TURN) Extension for IPv6](https://datatracker.ietf.org/doc/html/rfc6156#autoid-7)
1213

1314
This project is in early stage of development and some of the features described in the RFCs might be missing.
1415
Expect breaking changes.
@@ -43,7 +44,7 @@ pc = new RTCPeerConnection({
4344
});
4445
```
4546

46-
## Installation
47+
## Installation and running
4748

4849
1. From source
4950

@@ -57,77 +58,15 @@ mix run --no-halt
5758
2. In Docker
5859

5960
```console
60-
docker run ghcr.io/elixir-webrtc/rel:latest
61+
docker run --network=host ghcr.io/elixir-webrtc/rel:latest
6162
```
6263

6364
## Features and configuration
6465

65-
Currently, Rel is configured via environment variables.
66+
Rel exposes Prometheus metrics endpoint (by default `http://127.0.0.1:9568/metrics`).
6667

67-
### TURN server
68-
69-
Rel by default listens on `0.0.0.0:3478/UDP` for TURN traffic. This can be configured via `LISTEN_IP` and `LISTEN_PORT`.
70-
71-
```console
72-
LISTEN_IP=0.0.0.0
73-
LISTEN_PORT=3478
74-
```
75-
76-
`EXTERNAL_LISTEN_IP` is the IP address at which Rel is visible to clients. By default, Rel will try to guess the address
77-
based on active network interfaces, but this must be set explicitly when e.g. using Docker without `--network host`.
78-
79-
```console
80-
EXTERNAL_LISTEN_IP=167.235.241.140
81-
```
82-
83-
By default, Rel will use the same addresses (`RELAY_IP == LISTEN_IP and EXTERNAL_RELAY_IP == EXTERNAL_LISTEN_IP`) to open allocations, but this
84-
can be set to something else:
85-
86-
```console
87-
RELAY_IP=0.0.0.0
88-
EXTERNAL_RELAY_IP=167.235.241.140
89-
```
90-
91-
Rel will try to open relay addresses in `49_152 - 65_535` port range, but this can be changed. `RELAY_PORT_END` must be greater than `RELAY_PORT_START`.
92-
93-
```console
94-
RELAY_PORT_START=35000
95-
RELAY_PORT_END=45000
96-
```
97-
98-
Remember to use the `REALM` variable specific to your deployment. It's used in `REALM` STUN attributes. See
99-
[this section of RFC 2617](https://datatracker.ietf.org/doc/html/rfc2617#section-3.2.1) to learn about appropriate values for `REALM` attribute.
100-
101-
```console
102-
REALM=my-amazing-turn.com
103-
```
104-
105-
You can configure the number of running `listener` processes. By default, it is equal to number of running Erlang VM schedulers:
106-
107-
```console
108-
LISTENER_COUNT=8
109-
```
110-
111-
### Auth
112-
113-
Auth Provider is an HTTP endpoint that provides credentials required by *A REST API For Access To TURN Services*.
114-
By default it is available at `http://127.0.0.1:4000/`, but the address, encryption and CORS can be configured:
115-
116-
```console
117-
AUTH_IP=127.0.0.1
118-
AUTH_PORT=4000
119-
AUTH_USE_TLS=false
120-
AUTH_KEYFILE=./rel.key
121-
AUTH_CERTFILE./rel.cert
122-
AUTH_ALLOW_CORS=false
123-
```
124-
125-
### Metrics
126-
127-
By default, Rel provides Prometheus metrics at `http://127.0.0.1:9578/metrics`. The address can be configured:
128-
129-
```console
130-
METRICS_IP=127.0.0.1
131-
METRICS_PORT=9568
132-
```
68+
Rel supports authentication described in [A REST API For Access To TURN Services](https://datatracker.ietf.org/doc/html/draft-uberti-rtcweb-turn-rest-00#section-2.2).
69+
By default available under `http://127.0.0.1:4000/`. Example request would be `POST http://127.0.0.1:4000/&service=turn&username=johnsmith`.
70+
Key query parameter currently is not supported.
13371

72+
Rel is configured via environment variables. All of the possible options are described in [sample env file](./sample.env).

sample.env

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Rel config env variables
2+
3+
# Values presented in this example file are used by default
4+
# except where explicitly specified otherwise
5+
6+
## TURN
7+
8+
# Server address and port on which Rel listens for TURN/STUN requests
9+
LISTEN_IP=0.0.0.0
10+
LISTEN_PORT=3478
11+
12+
# Server address as seen from the client
13+
# By default it is equal to LISTEN_PORT or (if LISTEN_PORT == 0.0.0.0) Rel
14+
# will try to guess the address based on host's network interfaces
15+
# It must be explicitly set when e.g. running in Docker without `--network=host`
16+
# EXTERNAL_LISTEN_IP=167.235.241.140
17+
18+
# Address and port range where relay address will be allocated
19+
RELAY_IP=0.0.0.0
20+
RELAY_PORT_START=49152
21+
RELAY_PORT_END=65535
22+
23+
# Relay address as seen from peers
24+
# Behave the same way as EXTERNAL_LISTEN_IP
25+
# EXTERNAL_RELAY_IP=167.235.241.140
26+
27+
# Values used in REALM STUN attribute, see https://datatracker.ietf.org/doc/html/rfc5389#section-15.7
28+
REALM=example.com
29+
30+
# Number of running listener processes. By default equal to number of running Erlang VM schedulers
31+
# LISTENER_COUNT=8
32+
33+
## AUTH PROVIDER
34+
35+
# Auth provider is available under http(s)://$AUTH_IP:$AUTH_PORT/
36+
AUTH_IP=127.0.0.1
37+
AUTH_PORT=4000
38+
39+
# whether to use HTTP or HTTPS
40+
# If true, AUTH_KEYFILE and AUTH_CERFILE must be explicitly set
41+
AUTH_USE_TLS=false
42+
# AUTH_KEYFILE=./rel.key
43+
# AUTH_CERTFILE=./rel.cert
44+
45+
# Whether to allos Cross-Origin Resource Sharing
46+
# May be useful when requesting credentials via JavaScript in the browser
47+
AUTH_ALLOW_CORS=false
48+
49+
## METRICS
50+
51+
# Prometheus metrics are served on http://$METRICS_IP:$METRICS_PORT/metrics
52+
METRICS_IP=127.0.0.1
53+
METRICS_PORT=9568

0 commit comments

Comments
 (0)