current position:Home>Use nginx proxy node red under centos7 and realize password access

Use nginx proxy node red under centos7 and realize password access

2022-04-29 15:53:32Mischief 1124

1. Environmental installation

(1)nodejs

(2)node-red

(3)pm2( Startup and self startup need )

front 3 Please install your own Baidu or reference blog

Centos7 achieve Node-RED Boot up 、 Enable login function _ Little mischief 1124 The blog of -CSDN Blog

(4)nginx

yum install -y nginx

(5) Password generation tool

yum install -y httpd-tools

2. To configure

(1) modify settings.js Root path

  • File path : Under the current user directory .node-red/settings.js,

         for example /root/.node-red/settings.js

  • Parameters change

        httpAdminRoot: '/node-red'

  • restart node-red

explain : After restart, the access path is :http://127.0.0.1:1880/node-red

(2)nginx To configure

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

explain :
/node-red/comms: The agent is ws
/node-red: The agent is http

(3) If you need to enable password configuration

  • User password generation
htpasswd -c -d /etc/nginx/conf.d/noderedpwd admin
 or 
htpasswd -bdc /etc/nginx/conf.d/noderedpwd admin 123456
  • open auth_basic and auth_basic_user_file Configuration of , The password file path should correspond to

  •   Password file format
admin:uzpZjljZuNBfI

copyright notice
author[Mischief 1124],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291421205306.html

Random recommended