You are on page 1of 10

How to install and configure Node-RED on Ubuntu 16.

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

$ sudo apt-get install nodejs-legacy

-legacy

1/14/2017 4:38 AM

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

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

$ sudo apt-get install npm

npm

$ npm -v

3.5.2

npm

npm

node-red

node-red-admin

$ sudo npm install -g --unsafe-perm node-red node-red-admin

npm

-g
/usr/local/bin

--unsafe-perm

npm

1880

$ sudo ufw allow 1880

sudo

1880

$ node-red
S CR O L L TO TO P

1/14/2017 4:38 AM

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

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

$ sudo nano /etc/systemd/system/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

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

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

# 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]
WantedBy=multi-user.target

WantedBy

S CR O L L TO TO P

1/14/2017 4:38 AM

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

5 dari 10

https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node...

$ sudo systemctl enable node-red

$ sudo systemctl start node-red

1880

$ sudo systemctl stop node-red

443

$ sudo nano /etc/nginx/sites-enabled/node-red.example.com

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

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

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;
}

$ sudo systemctl reload nginx

$ sudo systemctl start node-red

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

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

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",

$ sudo ufw deny 1880

$ sudo systemctl restart node-red

https://node-red.example.com

S CR O L L TO TO P

1/14/2017 4:38 AM

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

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

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

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

How to install and configure Node-RED on Ubuntu 16.04 | DigitalOcean

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

You might also like