mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	removed use_proxy config, cleaned-up some comments and sneaked in a time log print on initialization, also, related to pull#820
This commit is contained in:
		
							
								
								
									
										1
									
								
								app.js
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								app.js
									
									
									
									
									
								
							@@ -74,6 +74,7 @@
 | 
				
			|||||||
		nconf.set('upload_url', path.join(path.sep, nconf.get('relative_path'), 'uploads', path.sep));
 | 
							nconf.set('upload_url', path.join(path.sep, nconf.get('relative_path'), 'uploads', path.sep));
 | 
				
			||||||
		nconf.set('base_dir', __dirname);
 | 
							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('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')));
 | 
							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')));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,12 +26,6 @@ var async = require('async'),
 | 
				
			|||||||
			'default': (nconf.get('use_port') !== undefined ? (nconf.get('use_port') ? 'y' : 'n') : 'y'),
 | 
								'default': (nconf.get('use_port') !== undefined ? (nconf.get('use_port') ? 'y' : 'n') : 'y'),
 | 
				
			||||||
			pattern: /y[es]*|n[o]?/,
 | 
								pattern: /y[es]*|n[o]?/,
 | 
				
			||||||
			message: 'Please enter \'yes\' or \'no\''
 | 
								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',
 | 
								name: 'secret',
 | 
				
			||||||
			description: 'Please enter a NodeBB secret',
 | 
								description: 'Please enter a NodeBB secret',
 | 
				
			||||||
@@ -147,7 +141,6 @@ var async = require('async'),
 | 
				
			|||||||
							config.bcrypt_rounds = 12;
 | 
												config.bcrypt_rounds = 12;
 | 
				
			||||||
							config.upload_path = '/public/uploads';
 | 
												config.upload_path = '/public/uploads';
 | 
				
			||||||
							config.use_port = config.use_port.slice(0, 1) === 'y';
 | 
												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),
 | 
												var urlObject = url.parse(config.base_url),
 | 
				
			||||||
								relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '',
 | 
													relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -191,23 +191,11 @@ if(nconf.get('ssl')) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				app.use(express.csrf());
 | 
									app.use(express.csrf());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// negative boolean with type check here to support a config.json without a 'use_proxy' value,
 | 
									if (nconf.get('port') != 80 && nconf.get('port') != 443 && nconf.get('use_port') === true) {
 | 
				
			||||||
				// so unless it's specifically set to false, it's true (as long as it's not a dev env)
 | 
										winston.info('Enabling \'trust proxy\'');
 | 
				
			||||||
				// 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.');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					app.enable('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
 | 
									// Local vars, other assorted setup
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user