可利用以下属性对Node-RED进行配置。
当作为一个独立程序运行时,这些属性可以从settings.js
文件中获得,该文件的存放位置可能为:
--settings|-s
设置--userDir|-u
指定的用户目录$HOME/.node-red/settings.js
Node-RED中包含一个默认的settings.js
文件,当用户没有提供配置文件,就会使用这个文件。另外,它也可作为你创建自有配置文件的起点,在这里可以找到它的源码。
而当以嵌入式方式运行时,则须通过调用RED.init()
传入配置参数。这种方式有可能会使其中的某些属性被忽略,但可以通过所嵌入的程序替代实现。
flows_<hostname>.json
$HOME/.node-red
nodes
子目录。该属性允许指定一个额外的目录,这样就可以将节点安装在Node-RED系统之外了。默认值: $HOME/.node-red/nodes
0.0.0.0
-
所有IPv4接口。
仅适用于独立运行方式.
1880
.
仅适用于独立运行方式.
false
, 则所有管理员服务端点将被禁用,包括API端点和编辑器界面。如果想只禁用编辑器界面,请查看后面的disableEditor
属性,默认值: /
adminAuth
。
在编辑器界面上启用HTTP基本身份认证:
httpAdminAuth: {user:"nol", pass:"5f4dcc3b5aa765d61d8327deb882cf99"}
pass
属性为实际密码的md5哈希值,以下命令可用于产生该数值:
node -e "console.log(require('crypto').createHash('md5').update('YOUR PASSWORD HERE','utf8').digest('hex'))"
仅适用于独立运行方式.
false
,则所有基于节点的HTTP服务端点被禁用。默认值: /
httpAdminAuth
。httpAdminRoot
和httpNodeRoot
所设置的值。仅适用于独立运行方式.
true
,将会阻止运行时显示编辑器界面,但管理员应用接口将保持可用。默认值: false
./
访问。当使用该属性时,必须同时使用httpAdminRoot
属性,将编辑器界面指向/
以外的其他路径。
仅适用于独立运行方式.
httpAdminAuth
。httpNodeMiddleware: function(req,res,next) {
// Perform any processing on the request.
// Be sure to call next() if the request should be passed
// to the relevant HTTP In node.
}
The default level is info
. For embedded devices with limited flash storage you may wish to set this to fatal
to minimise writes to “disk”.
['subflows', 'input', 'output', 'function', 'social', 'storage', 'analysis', 'advanced'],
Note: Until the user creates a subflow the subflow category will be empty and will not be visible in the palette.
The theme of the editor can be changed by using the following settings object. All parts are optional.
editorTheme: {
page: {
title: "Node-RED",
favicon: "/absolute/path/to/theme/icon",
css: "/absolute/path/to/custom/css/file"
},
header: {
title: "Node-RED",
image: "/absolute/path/to/header/image", // or null to remove image
url: "http://nodered.org" // optional url to make the header text/image a link to this url
},
deployButton: {
type:"simple",
label:"Save",
icon: "/absolute/path/to/deploy/button/image" // or null to remove image
},
menu: { // Hide unwanted menu items by id. see editor/js/main.js:loadEditor for complete list
"menu-item-import-library": false,
"menu-item-export-library": false,
"menu-item-keyboard-shortcuts": false,
"menu-item-help": {
label: "Alternative Help Link Text",
url: "http://example.com"
}
},
userMenu: false, // Hide the user-menu even if adminAuth is enabled
login: {
image: "/absolute/path/to/login/page/big/image" // a 256x256 image
}
},
ui : { path: “mydashboard” },
Any node type can define its own settings to be provided in the file.
functionGlobalContext: { osModule:require('os') }
can be accessed in a function node as:
var myos = global.get('osModule');
context
:
context.global.foo = "bar"; var osModule = context.global.osModule;This method is still supported, but deprecated in favour of the
global.get
/global.set
functions. This is in anticipation of being able to persist the context data in a future release.