1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add settings.uiHost - to allow binding to a specific interface

Closes #58
This commit is contained in:
Nicholas O'Leary 2013-11-08 14:50:54 +00:00
parent cb6fbf29a8
commit a2e77471a9
2 changed files with 14 additions and 3 deletions

11
red.js
View File

@ -39,6 +39,7 @@ if (settings.httpRoot.slice(-1) != "/") {
settings.httpRoot = settings.httpRoot + "/"; settings.httpRoot = settings.httpRoot + "/";
} }
settings.uiPort = settings.uiPort||1880; settings.uiPort = settings.uiPort||1880;
settings.uiHost = settings.uiHost||"0.0.0.0";
if (settings.httpAuth) { if (settings.httpAuth) {
app.use(settings.httpRoot, app.use(settings.httpRoot,
@ -55,13 +56,17 @@ app.use(settings.httpRoot,red);
RED.start(); RED.start();
server.listen(settings.uiPort,function() { var listenPath = 'http'+(settings.https?'s':'')+'://'+
util.log('[red] Server now running at http'+(settings.https?'s':'')+'://127.0.0.1:'+settings.uiPort+settings.httpRoot); (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) { process.on('uncaughtException',function(err) {
if (err.errno === "EADDRINUSE") { 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'); util.log('[red] Error: port in use');
} else { } else {
util.log('[red] Uncaught Exception:'); util.log('[red] Uncaught Exception:');

View File

@ -15,6 +15,12 @@
**/ **/
module.exports = { module.exports = {
uiPort: 1880, 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, mqttReconnectTime: 15000,
serialReconnectTime: 15000, serialReconnectTime: 15000,
debugMaxLength: 1000, debugMaxLength: 1000,