Skip to content

Commit 4d2ab62

Browse files
feat: reverse proxy configuration (#614)
* feat: reverse proxy configuration * chore: changeset * chore(wilbur): Fixing linting issues. --------- Co-authored-by: Matthew.Cotton <matt@tensorworks.com.au>
1 parent fd90d53 commit 4d2ab62

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.changeset/red-turtles-cross.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@epicgames-ps/wilbur': minor
3+
---
4+
5+
Adds command line options to wilbur to allow for configuring the reverse proxy:
6+
7+
--reverse-proxy Enables reverse proxy mode. This will
8+
trust the X-Forwarded-For header.
9+
(default: false)
10+
--reverse-proxy-num-proxies <number> Sets the number of proxies to trust.
11+
This is used to calculate the real
12+
client IP address. (default: 1)

SignallingWebServer/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
"ssl_cert_path": "certificates/client-cert.pem",
1515
"https_redirect": true,
1616
"rest_api": false,
17+
"reverse_proxy": false,
18+
"reverse_proxy_num_proxies": 1,
1719
"peer_options": "",
1820
"log_config": true,
1921
"stdin": false,
2022
"console_messages": "verbose"
21-
}
23+
}

SignallingWebServer/src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,19 @@ program
147147
.argParser(JSON.parse)
148148
.default(config_file.peer_options || '')
149149
)
150+
.option(
151+
'--reverse-proxy',
152+
'Enables reverse proxy mode. This will trust the X-Forwarded-For header.',
153+
config_file.reverse_proxy || false
154+
)
155+
.addOption(
156+
new Option(
157+
'--reverse-proxy-num-proxies <number>',
158+
'Sets the number of proxies to trust. This is used to calculate the real client IP address.'
159+
)
160+
.implies({ reverse_proxy: true })
161+
.default(config_file.reverse_proxy_num_proxies || 1)
162+
)
150163
.option(
151164
'--log_config',
152165
'Will print the program configuration on startup.',
@@ -197,6 +210,9 @@ if (options.log_config) {
197210
}
198211

199212
const app = express();
213+
if (options.reverse_proxy) {
214+
app.set('trust proxy', options.reverse_proxy_num_proxies);
215+
}
200216

201217
const serverOpts: IServerConfig = {
202218
streamerPort: options.streamer_port,

0 commit comments

Comments
 (0)