diff --git a/config/default.yaml b/config/default.yaml index bf772faf6bb129e9229f4ef1988852dd5999a574..9f4a76621d08ba74e87144d2e1377db7d28182f0 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 c963118d943a6759824faa1aa4e330d87dbfbc86..fc06c51fb7d2e4e7e72a5bbdf16e2a99b90a0fc5 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 06d575c861c8d7ae705075b9e1beed18bfc3e5a6..5323bae2b423677bf3322fdf510485bfdd18e212 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 45f1d79c33844e699df90e4c004ccfebbcf22f68..71f3039634075ed7532a802b9d30dc55938b87d7 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 2622b2c71a2561b735a31dbbcc25f4914f85cba2..56d39529e60f0e26268172f583717f54072a7f2c 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 7b6de32e51e645c25197be0ab0f1e91ee6804d90..8a58c5b16b3e67f61365cde511ec86c898a30564 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