I have been playing with node-red this weekend on my local machine, and just launched it to a IIS server i have.
On my local host i ran node-red globally, but in production i'm running it from my www-root (using iisnode). I have an app.js file where i've stolen this code:
var http = require('http');
var express = require("express");
var RED = require("node-red");
// Create an Express app
var app = express();
// Add a simple route for static content served from 'public'
app.use("/",express.static("public"));
// Create a server
var server = http.createServer(app);
// Create the settings object - see default settings.js file for other options
var settings = {
httpAdminRoot:"/admin",
httpNodeRoot: "/",
userDir:"./.nodered/",
adminAuth:{
type: "credentials",
users: [
{
username: "admin",
password: "xxxx",
permissions: "*"
}
]
},
httpNodeAuth: {user:"fred",pass:"yyyy"},
ui: {
path: "/"
},
functionGlobalContext: { } // enables global context
};
//var settings=require('./settings.js');
// Initialise the runtime with a server and settings
RED.init(server,settings);
// Serve the editor UI from /red
app.use(settings.httpAdminRoot,RED.httpAdmin);
// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot,RED.httpNode);
server.listen(process.env.PORT);
// Start the runtime
RED.start();
I'm not really sure about the black magic goin on with app.use (x2) before server.listen. I know that this is the express way of registering routes, and i suspect it's something here i need to password protect the ui/dashboard?
The admin section works just fine with credentials.
Any suggestions about what to do?