aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPierre-Alain TORET <pierre-alain.toret@protonmail.com>2018-04-17 11:14:32 +0200
committerChocobozzz <me@florianbigard.com>2018-04-17 11:14:32 +0200
commitcff8b272b1631661b8d5f5f4b59bd534ad8c86ca (patch)
tree465cb9a49289e3695d60917f02974afd16799b27
parentc0c7416a233d1bf1ed197b8f383aca74bc27c3f0 (diff)
downloadPeerTube-cff8b272b1631661b8d5f5f4b59bd534ad8c86ca.tar.gz
PeerTube-cff8b272b1631661b8d5f5f4b59bd534ad8c86ca.tar.zst
PeerTube-cff8b272b1631661b8d5f5f4b59bd534ad8c86ca.zip
Support hostname binding in config
* Add basic support for hostname binding Signed-off-by: Pierre-Alain TORET <pierre-alain.toret@protonmail.com> * Make production example a bit more secure Signed-off-by: Pierre-Alain TORET <pierre-alain.toret@protonmail.com> * Make example config files compatible with hostname binding modification Signed-off-by: Pierre-Alain TORET <pierre-alain.toret@protonmail.com> * Fix typo Signed-off-by: Pierre-Alain TORET <pierre-alain.toret@protonmail.com> * Bind on 127.0.0.1 by default Signed-off-by: Pierre-Alain TORET <pierre-alain.toret@protonmail.com> * Update Docker configuration with hostname binding Signed-off-by: Pierre-Alain TORET <pierre-alain.toret@protonmail.com>
-rw-r--r--config/default.yaml1
-rw-r--r--config/production.yaml.example1
-rw-r--r--server.ts5
-rw-r--r--server/initializers/checker.ts2
-rw-r--r--server/initializers/constants.ts3
-rw-r--r--support/docker/production/config/production.yaml1
6 files changed, 9 insertions, 4 deletions
diff --git a/config/default.yaml b/config/default.yaml
index bf772faf6..9f4a76621 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -1,4 +1,5 @@
1listen: 1listen:
2 hostname: '127.0.0.1'
2 port: 9000 3 port: 9000
3 4
4webserver: 5webserver:
diff --git a/config/production.yaml.example b/config/production.yaml.example
index c963118d9..fc06c51fb 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -1,4 +1,5 @@
1listen: 1listen:
2 hostname: 'localhost'
2 port: 9000 3 port: 9000
3 4
4# Correspond to your reverse proxy "listen" configuration 5# Correspond to your reverse proxy "listen" configuration
diff --git a/server.ts b/server.ts
index 06d575c86..5323bae2b 100644
--- a/server.ts
+++ b/server.ts
@@ -194,6 +194,7 @@ app.use(function (err, req, res, next) {
194 194
195async function startApplication () { 195async function startApplication () {
196 const port = CONFIG.LISTEN.PORT 196 const port = CONFIG.LISTEN.PORT
197 const hostname = CONFIG.LISTEN.HOSTNAME
197 198
198 await installApplication() 199 await installApplication()
199 200
@@ -214,7 +215,7 @@ async function startApplication () {
214 Redis.Instance.init() 215 Redis.Instance.init()
215 216
216 // Make server listening 217 // Make server listening
217 server.listen(port) 218 server.listen(port, hostname)
218 logger.info('Server listening on port %d', port) 219 logger.info('Server listening on %s:%d', hostname, port)
219 logger.info('Web server: %s', CONFIG.WEBSERVER.URL) 220 logger.info('Web server: %s', CONFIG.WEBSERVER.URL)
220} 221}
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index 45f1d79c3..71f303963 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -18,7 +18,7 @@ function checkConfig () {
18 18
19// Check the config files 19// Check the config files
20function checkMissedConfig () { 20function checkMissedConfig () {
21 const required = [ 'listen.port', 21 const required = [ 'listen.port', 'listen.hostname',
22 'webserver.https', 'webserver.hostname', 'webserver.port', 22 'webserver.https', 'webserver.hostname', 'webserver.port',
23 'trust_proxy', 23 'trust_proxy',
24 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 24 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 2622b2c71..56d39529e 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -86,7 +86,8 @@ let SCHEDULER_INTERVAL = 60000 * 60
86const CONFIG = { 86const CONFIG = {
87 CUSTOM_FILE: getLocalConfigFilePath(), 87 CUSTOM_FILE: getLocalConfigFilePath(),
88 LISTEN: { 88 LISTEN: {
89 PORT: config.get<number>('listen.port') 89 PORT: config.get<number>('listen.port'),
90 HOSTNAME: config.get<string>('listen.hostname')
90 }, 91 },
91 DATABASE: { 92 DATABASE: {
92 DBNAME: 'peertube' + config.get<string>('database.suffix'), 93 DBNAME: 'peertube' + config.get<string>('database.suffix'),
diff --git a/support/docker/production/config/production.yaml b/support/docker/production/config/production.yaml
index 7b6de32e5..8a58c5b16 100644
--- a/support/docker/production/config/production.yaml
+++ b/support/docker/production/config/production.yaml
@@ -1,4 +1,5 @@
1listen: 1listen:
2 hostname: '127.0.0.1'
2 port: 9000 3 port: 9000
3 4
4# Correspond to your reverse proxy "listen" configuration 5# Correspond to your reverse proxy "listen" configuration