Install Node Red
Install Node Red
04 | DigitalOcean
1 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
node-red.example.com
cron
-legacy
1/14/2017 4:38 AM
2 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
node
nodejs
$ node -v
v4.2.6
npm
npm
apt-get
npm
$ npm -v
3.5.2
npm
npm
node-red
node-red-admin
npm
-g
/usr/local/bin
--unsafe-perm
npm
1880
sudo
1880
$ node-red
S CR O L L TO TO P
1/14/2017 4:38 AM
3 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
1880
http://node-red.example.com:1880
CTRL+C
node-red.service
systemd
node-red.service
[Unit]
Description=Node-RED
After=syslog.target network.target
[Service]
ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v
Restart=on-failure
KillSignal=SIGINT
# log output to syslog as 'node-red'
SyslogIdentifier=node-red
StandardOutput=syslog
# non-root user to run as
WorkingDirectory=/home/sammy/
User=sammy
Group=sammy
[Install]
S CR O L L TO TO P
1/14/2017 4:38 AM
4 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
WantedBy=multi-user.target
[Unit]
Description=Node-RED
After=syslog.target network.target
[Service]
ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v
Restart=on-failure
KillSignal=SIGINT
ExecStart
node-red-pi
node-red
Restart=on-failure
KillSignal
[Install]
WantedBy=multi-user.target
WantedBy
S CR O L L TO TO P
1/14/2017 4:38 AM
5 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
1880
443
server {
listen 80;
listen 443 ssl http2;
server_name node-red.example.com;
ssl_certificate /etc/letsencrypt/live/node-red.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/node-red.example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers On;
ssl_session_cache shared:SSL:128m;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8;
location / {
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
proxy_pass http://localhost:1880;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location '/.well-known/acme-challenge' {
root /var/www/html;
}
}
S CR O L L TO TO P
1/14/2017 4:38 AM
6 dari 10
ssl_certificate
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
ssl_certificate_key
ssl_
location /
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
proxy_pass http://localhost:1880;
localhost
Upgrade
1880
Connection
location '/.well-known/acme-challenge' {
root /var/www/html;
}
http://node-red.example.com
https://node-red.example.com
node-red-admin
https
S CR O L L TO TO P
1/14/2017 4:38 AM
7 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
$ node-red-admin hash-pw
ENTER
$ nano ~/.node-red/settings.js
adminAuth
username
password
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2a$08$Ab9prIr1M8a5a1/Zx8.B9.uIOCPe.v90ZGuZc2kAATp6BHJ/WV5KS",
permissions: "*"
}]
},
uihost
//
uiHost: "127.0.0.1",
https://node-red.example.com
S CR O L L TO TO P
1/14/2017 4:38 AM
8 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
https
S CR O L L TO TO P
1/14/2017 4:38 AM
9 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
npm
S CR O L L TO TO P
1/14/2017 4:38 AM
10 dari 10
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...
dashboard
node-red-dashboard
node-rednode-red-contrib-
S CR O L L TO TO P
1/14/2017 4:38 AM