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.
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