Deploying thiab configuring node-red authentication ntawm docker-compose

Deploying thiab configuring node-red authentication ntawm docker-compose

Deploying node-red on docker-compose with authorization enabled thiab siv docker ntim.

Tsim cov ntaub ntawv docker-compose.yml:

version: "3.7"

services:
  node-red:
    image: nodered/node-red
    environment:
      - TZ=Europe/Moscow
    ports:
      - "11880:1880" # 11880 - ΠΏΠΎΡ€Ρ‚ для ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΡ ΠΊ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€Ρƒ, 1880 - ΠΏΠΎΡ€Ρ‚ Π½Π° ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚ node-red Π²Π½ΡƒΡ‚Ρ€ΠΈ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€Π°.
    volumes:
      - "node-red:/data" # node-red - ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π²Ρ‹Π΄Π΅Π»ΠΈΡ‚ docker для хранСния Π΄Π°Π½Π½Ρ‹Ρ…, /data - ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ Π²Π½ΡƒΡ‚Ρ€ΠΈ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€Π°.
    restart: always
volumes:
  node-red: # созданиС ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π° node-red Π½Π° хостС.


Peb tso lub thawv rau hauv hom kev debug (thawj tso tawm yuav tsum tsis muaj 'tus yuam sij-d`, saib qhov yuam kev thaum lawv tshwm):

$ docker-compose up node-red
Creating node-red_node-red_1_3e3e59f5e044 ... done
Attaching to node-red_node-red_1_bca4cb987984
node-red_1_bca4cb987984 |
node-red_1_bca4cb987984 | > [email protected] start /usr/src/node-red
node-red_1_bca4cb987984 | > node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"
...

Nres lub thawv thiab khiav cov lus txib kom pom ntim:

$ docker volume ls
DRIVER              VOLUME NAME
local               node-red_node-red

Peb saib cov ncauj lus kom ntxaws txog ntim:

$ docker volume inspect node-red_node-red
[
    {
        "CreatedAt": "2020-05-02T18:37:33Z",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "node-red",
            "com.docker.compose.version": "1.23.0",
            "com.docker.compose.volume": "node-red"
        },
        "Mountpoint": "/var/lib/docker/volumes/node-red_node-red/_data", # расолоТСниС нашСго ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π°
        "Name": "node-red_node-red",
        "Options": null,
        "Scope": "local"
    }
]

Mus rau lub ntim directory. Daim ntawv teev npe no twb muaj cov ntaub ntawv uas docker tsim thaum siv lub thawv.

$ sudo ls /var/lib/docker/volumes/node-red_node-red/_data
lib  package.json  settings.js

Peb txaus siab rau cov ntaub ntawv settings.js. Qhib nws thiab nrhiav ib daim code adminAuth. Wb tsis hais nws.

 // Securing Node-RED
    // -----------------
    // To password protect the Node-RED editor and admin API, the following
    // property can be used. See http://nodered.org/docs/security.html for details.
    adminAuth: {
        type: "credentials",
        users: [{
            username: "admin",
            password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
            permissions: "*"
        }]
    },

Hauv tus yuam sij lo lus zais: koj yuav tsum tau ntxig tus node-liab password hash.

Tau txais node-red password hash
Nruab node-red-admin pob ntawm txhua lub tshuab khiav node.js.

npm i node-red-admin -g

Khiav lub pob thiab teeb tus password:

node-red-admin hash-pw

Tua lub thawv thiab txuas mus rau qhov chaw nres nkoj 11880.

http://192.168.0.100:11880/

Lub qhov rais tso cai yuav tsum tshwm.

Deploying thiab configuring node-red authentication ntawm docker-compose

Sau koj tus password nkag mus.

Yog tias txhua yam ua haujlwm, rov pib lub thawv nrog tus yuam sij -d.

$ docker-compose up -d node-red

Tej yam zoo li no.

Tau qhov twg los: www.hab.com

Ntxiv ib saib