Node-RED

Программирование с использованием технологий «low-code» для приложений, управляемых событиями.

Accessing Node-RED

  • Откройте браузер и перейдите по адресу: https://<SERVER_IP>
  • Ожидается появление предупреждения браузера о SSL (самоподписанный сертификат)
  • Authentication is required (Basic Auth popup)
  • Authentication method: HTTP Basic Auth
  • Credentials are stored securely in: /root/.cloudzy-creds

Важные файлы и каталоги

  • Main installation directory is /root/node-red.
  • Docker orchestration file is /root/node-red/docker-compose.yml.
  • Persistent Node-RED data is stored in /var/lib/docker/volumes/node-red_node-red-data/_data.
  • Nginx configuration file is located at /etc/nginx/sites-available/node-red.
  • Basic authentication credentials are stored in /etc/nginx/auth/node-red.htpasswd.
  • TLS certificates are stored in /etc/nginx/ssl.

Управление услугами

Проверить состояние контейнера:

docker ps

Просмотр журналов:

docker compose -f /root/node-red/docker-compose.yml logs -f

Restart Node-RED:

docker compose -f /root/node-red/docker-compose.yml restart

Перезапустите Nginx:

systemctl restart nginx

Node-RED Admin User (Alternative to Basic Auth)

Node-RED has its own internal authentication system, which can replace HTTP Basic Auth.

1. Locate settings.js

The main configuration file is inside the Node-RED Docker volume: /var/lib/docker/volumes/node-red_node-red-data/_data/settings.js

2. Enable adminAuth

Открыть settings.js and uncomment (or add) the adminAuth section. It should look something like this:

  adminAuth: {
      type: "credentials",
      users: [
          {
              username: "admin",
              password: "<HASHED_PASSWORD>",
              permissions: "*"
      }]
  },

3. Generate a password hash

You can generate the hash from inside the Node-RED container:

docker exec -it node-red-node-red-1 node-red admin hash-pw

You will be prompted to enter your plain password.

Copy the resulting hash and paste it as the password value in settings.js.

4. Restart Node-RED

After editing settings.js:

docker compose -f /root/node-red/docker-compose.yml restart

5. Disable HTTP Basic Auth in Nginx (Optional)

Edit the Nginx site file: /etc/nginx/sites-available/node-red

Remove or comment out these lines:

auth_basic "Restricted";
auth_basic_user_file /etc/nginx/auth/node-red.htpasswd;

Перезагрузите Nginx:

systemctl restart nginx

Включение SSL с доменом

1. Направьте ваш домен на IP-адрес сервера.

2. Отредактируйте конфигурацию Nginx и замените оба server_name <IP>; с вашим доменом (<your-domain>) для блоков HTTP (порт 80) и HTTPS (порт 443):

vim /etc/nginx/sites-available/node-red

3. Установите Certbot:

apt install -y certbot python3-certbot-nginx

4. Выполните следующую команду, чтобы сгенерировать действительный сертификат Let’s Encrypt:

certbot certonly --nginx --non-interactive --agree-tos --email [email protected] -d yourdomain.com

5. Замените пути SSL в конфигурации Nginx:

vim /etc/apache2/sites-available/node-red
# Before:
    # ssl_certificate /etc/nginx/ssl/fullchain.pem;
    # ssl_certificate_key /etc/nginx/ssl/privkey.pem;
# After:
    # ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    # ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

6. Перезапустите Nginx, чтобы применить изменения:

systemctl restart nginx

7. Откройте браузер и перейдите по адресу: https://yourdomain.com

Детали заявки