Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Support hostname binding in config

Pierre-Alain TORETcff8b272b163
diff --git a/config/default.yaml b/config/default.yaml
index bf772faf6b..9f4a76621d 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -1,4 +1,5 @@
listen:
+ hostname: '127.0.0.1'
port: 9000
webserver:
diff --git a/config/production.yaml.example b/config/production.yaml.example
index c963118d94..fc06c51fb7 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -1,4 +1,5 @@
listen:
+ hostname: 'localhost'
port: 9000
# Correspond to your reverse proxy "listen" configuration
diff --git a/server.ts b/server.ts
index 06d575c861..5323bae2b4 100644
--- a/server.ts
+++ b/server.ts
@@ -194,6 +194,7 @@ app.use(function (err, req, res, next) {
async function startApplication () {
const port = CONFIG.LISTEN.PORT
+ const hostname = CONFIG.LISTEN.HOSTNAME
await installApplication()
@@ -214,7 +215,7 @@ async function startApplication () {
Redis.Instance.init()
// Make server listening
- server.listen(port)
- logger.info('Server listening on port %d', port)
+ server.listen(port, hostname)
+ logger.info('Server listening on %s:%d', hostname, port)
logger.info('Web server: %s', CONFIG.WEBSERVER.URL)
}
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index 45f1d79c33..71f3039634 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -18,7 +18,7 @@ function checkConfig () {
// Check the config files
function checkMissedConfig () {
- const required = [ 'listen.port',
+ const required = [ 'listen.port', 'listen.hostname',
'webserver.https', 'webserver.hostname', 'webserver.port',
'trust_proxy',
'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 2622b2c71a..56d39529e6 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -86,7 +86,8 @@ let SCHEDULER_INTERVAL = 60000 * 60
const CONFIG = {
CUSTOM_FILE: getLocalConfigFilePath(),
LISTEN: {
- PORT: config.get<number>('listen.port')
+ PORT: config.get<number>('listen.port'),
+ HOSTNAME: config.get<string>('listen.hostname')
},
DATABASE: {
DBNAME: 'peertube' + config.get<string>('database.suffix'),
diff --git a/support/docker/production/config/production.yaml b/support/docker/production/config/production.yaml
index 7b6de32e51..8a58c5b16b 100644
--- a/support/docker/production/config/production.yaml
+++ b/support/docker/production/config/production.yaml
@@ -1,4 +1,5 @@
listen:
+ hostname: '127.0.0.1'
port: 9000
# Correspond to your reverse proxy "listen" configuration