diff --git a/red.js b/red.js index f63ee64f5..43ea856a8 100644 --- a/red.js +++ b/red.js @@ -39,6 +39,7 @@ if (settings.httpRoot.slice(-1) != "/") { settings.httpRoot = settings.httpRoot + "/"; } settings.uiPort = settings.uiPort||1880; +settings.uiHost = settings.uiHost||"0.0.0.0"; if (settings.httpAuth) { app.use(settings.httpRoot, @@ -55,13 +56,17 @@ app.use(settings.httpRoot,red); RED.start(); -server.listen(settings.uiPort,function() { - util.log('[red] Server now running at http'+(settings.https?'s':'')+'://127.0.0.1:'+settings.uiPort+settings.httpRoot); +var listenPath = 'http'+(settings.https?'s':'')+'://'+ + (settings.uiHost == '0.0.0.0'?'127.0.0.1':settings.uiHost)+ + ':'+settings.uiPort+settings.httpRoot; + +server.listen(settings.uiPort,settings.uiHost,function() { + util.log('[red] Server now running at '+listenPath); }); process.on('uncaughtException',function(err) { if (err.errno === "EADDRINUSE") { - util.log('[red] Unable to listen on http'+(settings.https?'s':'')+'://127.0.0.1:'+settings.uiPort+settings.httpRoot); + util.log('[red] Unable to listen on '+listenPath); util.log('[red] Error: port in use'); } else { util.log('[red] Uncaught Exception:'); diff --git a/settings.js b/settings.js index 2dd19bb41..4ac02795e 100644 --- a/settings.js +++ b/settings.js @@ -15,6 +15,12 @@ **/ module.exports = { uiPort: 1880, + + // By default, the Node-RED UI accepts connections on all IPv4 interfaces. + // The following property can be used to listen on a specific interface. For + // example, the following would only allow connections from the local machine. + //uiHost: "127.0.0.1", + mqttReconnectTime: 15000, serialReconnectTime: 15000, debugMaxLength: 1000,