1.方式一
使用node-red自带的用户认证,详见下面这篇博客
Centos7下实现Node-RED开机自启动、启用登录功能_小捣蛋1124的博客-CSDN博客
2. 方式二
使用nginx代理的方式.
需要先设置node-red的根路径,修改settings.js的httpAdminRoot为node-red
(1)密码生成(账号:admin 密码:123456)
htpasswd -bdc /etc/nginx/conf.d/noderedpwd admin 123456
(2)nginx配置
location /node-red {
proxy_pass http://127.0.0.1:1880;
auth_basic "Please input username and password";
auth_basic_user_file /etc/nginx/conf.d/noderedpwd;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}
location /node-red/comms {
proxy_pass http://127.0.0.1:1880;
proxy_read_timeout 300s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
说明:
/node-red/comms:代理的是ws
/node-red:代理的是http