Add bind_address option (#349)

Add option to set the IP address the master server binds its HTTP and
HTTPS ports to.
This commit is contained in:
tovernaar123 authored and GitHub committed 2020-12-28 03:40:28 +01:00
1 parent 6204c73ef2
commit 35cb9f8698
3 files changed
+21 -2

No files matched your search

+11
View File
@@ -32,6 +32,17 @@ of this and master.http_port needs to be set to a port.
Defaults to 8443.
### master.bind_address
IP address to bind the HTTP and HTTPS ports on. Useful to limit which
interface to accept connections from. If set to null the unspecified
IPv6 address will be used, which on most systems means it will also
listen on the unspecified IPv4 address and accept connections from all
interfaces.
Defaults to null.
### master.external_address
External address the master server is accessible on. Currently only
+7
View File
@@ -33,6 +33,13 @@ MasterGroup.define({
optional: true,
initial_value: 8443,
});
MasterGroup.define({
name: "bind_address",
title: "Bind Address",
description: "IP address to bind the HTTP and HTTPS ports on.",
type: "string",
optional: true,
});
MasterGroup.define({
name: "external_address",
title: "External Address",
+3 -2
View File
@@ -1943,6 +1943,7 @@ async function startServer() {
// Make sure we're actually going to listen on a port
let httpPort = masterConfig.get("master.http_port");
let httpsPort = masterConfig.get("master.https_port");
let bindAddress = masterConfig.get("master.bind_address") || "";
if (!httpPort && !httpsPort) {
logger.fatal("Error: at least one of http_port and https_port must be configured");
process.exit(1);
@@ -1980,7 +1981,7 @@ async function startServer() {
// Only start listening for connections after all plugins have loaded
if (httpPort) {
httpServer = new (require("http").Server)(app);
await listen(httpServer, httpPort);
await listen(httpServer, httpPort, bindAddress);
logger.info(`Listening for HTTP on port ${httpServer.address().port}`);
}
@@ -2000,7 +2001,7 @@ async function startServer() {
key: privateKey,
cert: certificate,
}, app);
await listen(httpsServer, httpsPort);
await listen(httpsServer, httpsPort, bindAddress);
logger.info(`Listening for HTTPS on port ${httpsServer.address().port}`);
}
}