From dcc6ec797e9d03c5f8d6853fb1ac879604862d55 Mon Sep 17 00:00:00 2001 From: akhoury Date: Thu, 23 Jan 2014 20:35:53 -0500 Subject: [PATCH] removed use_proxy config, cleaned-up some comments and sneaked in a time log print on initialization, also, related to pull#820 --- app.js | 1 + src/install.js | 7 ------- src/webserver.js | 20 ++++---------------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/app.js b/app.js index 375a74c695..8dec4daa79 100644 --- a/app.js +++ b/app.js @@ -74,6 +74,7 @@ nconf.set('upload_url', path.join(path.sep, nconf.get('relative_path'), 'uploads', path.sep)); nconf.set('base_dir', __dirname); + winston.info('Time: ' + new Date()); winston.info('Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using ' + nconf.get('database') +' store at ' + nconf.get(nconf.get('database') + ':host') + ':' + nconf.get(nconf.get('database') + ':port') + '.'); winston.info('NodeBB instance bound to: ' + ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? 'Any address (0.0.0.0)' : nconf.get('bind_address'))); diff --git a/src/install.js b/src/install.js index eae4de5dfa..3ce7537831 100644 --- a/src/install.js +++ b/src/install.js @@ -26,12 +26,6 @@ var async = require('async'), 'default': (nconf.get('use_port') !== undefined ? (nconf.get('use_port') ? 'y' : 'n') : 'y'), pattern: /y[es]*|n[o]?/, message: 'Please enter \'yes\' or \'no\'' - }, { - name: 'use_proxy', - description: 'is NodeBB behind a proxy?', - 'default': (nconf.get('use_proxy') !== undefined ? (nconf.get('use_proxy') ? 'y' : 'n') : 'y'), - pattern: /y[es]*|n[o]?/, - message: 'Please enter \'yes\' or \'no\'' }, { name: 'secret', description: 'Please enter a NodeBB secret', @@ -147,7 +141,6 @@ var async = require('async'), config.bcrypt_rounds = 12; config.upload_path = '/public/uploads'; config.use_port = config.use_port.slice(0, 1) === 'y'; - config.use_proxy = config.use_proxy.slice(0, 1) === 'y'; var urlObject = url.parse(config.base_url), relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '', diff --git a/src/webserver.js b/src/webserver.js index 1dcc5df18b..ebffd122b2 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -191,23 +191,11 @@ if(nconf.get('ssl')) { app.use(express.csrf()); - // negative boolean with type check here to support a config.json without a 'use_proxy' value, - // so unless it's specifically set to false, it's true (as long as it's not a dev env) - // todo: remove double negative with a minor release, where backward compatibility can be broken - // and if dev mode, then it's probably not behind a proxy but it can be forced by setting 'use_proxy' to true - - if (nconf.get('use_proxy') === false) { - winston.info('\'use_proxy\' is set to false in config file, skipping \'trust proxy\''); - - } else if (!nconf.get('use_proxy') && process.env.NODE_ENV === 'development') { - winston.info('\'use_proxy\' is not set, skipping because you\'re in development env. Set to true to force enabling it.'); - - } else { - winston.info('\'use_proxy\'' - + (nconf.get('use_proxy') === true ? ' is set to true ' : ' is not set ') - + 'in config file, enabling \'trust proxy\', set to false to disable it.'); - + if (nconf.get('port') != 80 && nconf.get('port') != 443 && nconf.get('use_port') === true) { + winston.info('Enabling \'trust proxy\''); app.enable('trust proxy'); + } else if (process.env.NODE_ENV !== 'development') { + winston.info('Using ports 80 and 443 is not recommend; use a proxy instead. See README.md'); } // Local vars, other assorted setup