Sign inSign up

noycebe/netfield-node-red

By noycebe

•Updated about 2 months ago

Image
0

965

noycebe/netfield-node-red repository overview

⁠Info

Provides Node-RED with netFIELD V2 authentication, https and several useful common Node-RED nodes
Adapted from https://github.com/HilscherAutomation/netFIELD-nodered⁠ and https://github.com/node-red/node-red-docker/⁠
Need to be run on netFIELD OS > V2.0.0.0

⁠Docker Images

docker run -d --restart=always --pull=always --network=host -v nodereddata:/data --name mynodered noycebe/netfield-node-red:<tag>  
⁠netFIELD Container Create Options
{
  "HostConfig": {
    "Privileged": true,
    "NetworkMode": "host",
    "PortBindings": {
      "1880/tcp": [
        {
          "HostPort": "1880"
        }
      ]
    },
    "Mounts": [
      {
        "Type": "volume",
        "Source": "nodered",
        "Target": "/data",
        "ReadOnly": false,
        "Consistency": "consistent"
      }
    ]
  }
}
⁠Network Host Mode

The container must be run in host mode, otherwise the authentication will fail. In the user-authentication_v2.js the IP is 127.0.0.1 (localhost) to check for authentication. In bridge mode, this IP address needs to be adapted.

⁠Installed Node Modules

node-red-contrib-opcua
node-red-contrib-influxdb
node-red-contrib-modbus
node-red-dashboard
node-red-node-serialport

⁠Changes in Node-RED standard files

⁠settings.js
⁠set authentication to netFIELD V2
adminAuth: require("/data/user-authentication_v2.js"),
⁠enable https security and make certificates known
https: {
    key: require("fs").readFileSync('/data/certs/node-key.pem'),
    cert: require("fs").readFileSync('/data/certs/node-cert.pem')
},
⁠redirect insecure HTTP connections to HTTPS
requireHttps: true,
⁠entrypoint.sh
⁠insert certificate generation after #!/bin/bash in entrypoint.sh
if [ ! -e container_first_start ]; then
  echo "Container is starting the first time"
  mkdir -p /data/certs
  openssl genrsa -out /data/certs/node-key.pem 4096
  openssl req -new -sha256 -key /data/certs/node-key.pem -out /data/certs/node-csr.pem -subj "/C=DE/ST=Hessen/L=Hattersheim/O=Hilscher/OU=Hilscher/CN=$HOSTNAME/[email protected]"
  openssl x509 -req -days 365 -in /data/certs/node-csr.pem -signkey /data/certs/node-key.pem -out /data/certs/node-cert.pem
  touch container_first_start
fi' /usr/src/node-red/entrypoint.sh

Tag summary

Content type

Image

Digest

sha256:cb62e4fbb…

Size

422.6 MB

Last updated

about 2 months ago

docker pull noycebe/netfield-node-red:5.0.4