Docker ???? ????? Node.js ????????? ??? ???? NGINX ??? ??????????? ?????

Docker ???? ????? Node.js ????????? ??? ???? NGINX ??? ??????????? ?????

??????? ???? ???? ????????????????? ?????????????? ???????? Docker ?????? ???????????? ?????? ???? ??? ? ?? ???? ????? ?????? Docker ??????? ??? ????? Node.js ???????????? ????????? ??? ???? NGINX ??? ??????????? ????????? ???? ??? ????? ????? load distribution ??? ????

?????? ?? ??? ??????????? ??? ?????

?????? ???? ???? Node.js ??????? ???? ??? ????? NGINX ??????? ??? ???? ???? ??? ??????????? ???? ??? ?? ??? ??????????? ?????? Nodejs ??????? ????? ????? load distribution ???? ?????? ??? ????? ????????? ?????? ??? NGINX ??????????????? Node.js ????????? ????? ??? ??? ?????

Node.js ????????????? ?????? Node.js ?????????????? ???? ?????? ???? ??? ????????? ???????? ???? ???? ???? ??????? ??????? ???? ??? ????????? ???? ????????? ?? ????? ?????? ? ?????? ??????? Node.js ??????? ???? ????? hostname /container ? ??? ??? ??? NGINX ??????? ???? ?????????? ?????? ???, ??? Node.js ????????? ???????????? ????, ???????????? ???? ??? ????????? hostname ??????? ??? ????.


app.js file

??? ?? nodeJs app ???? ???? ??? container ?????? ?? ???? ?????? ???? ???? ???? ????? ? ????? ???? ???? ???? ???? ?????? ???? ?


docker file


???? ?????? ?????? ??? ???? ??? ???? ???? ???? ?????? ????? ??? ???? ???? node-app1 ??? node-app2 ???? ??? container ?????? ??? nginx ???? ???? nginx ?? ????? ???? container ?????? ? container ???? ??? ??????? ???? comunication ???? ???? ?? ???? ???? ?????? ????????? ?????? ?


commands

?????? NGINX ?? container ?? ?? ?????? listen ???? ??? node-app1 ? node-app2 ?? ????? ??? ??? ??? ?????

docker cp ?????? ??????? ??? ???? ?????? NGINX ?????????? ???? ??? ??? ??????????? ????? ?????, ????? NGINX ????????? ?????

????? NGINX ?? config ?????? ???? ???? ???


nginx.config

  • upstream ????? ???? ????? Node.js ????????? ?????? ?????? (?? ?????? Docker ?????????? ????)?
  • ????? weight ???? ??? ??? ??????????? ??? ????????? ?? ???? ????????? ??????? ????????????, node-app1 ?? weight ???? ??? ??? ?????? (3), ??? ???? ??? node-app2 ?? ???? ? ??? ???? ????????? ?????
  • server ?????? ?????, NGINX ?? ????? ?????? ???????????? ????????????? ????? ???? ??? ?????? node-apps ?? ???? ????????? ???????????? ????? ??? ??? ???????

Algorithm ?????? ??? ????

????? NGINX round-robin ???????? ??????? ???, ?? ??? ???????? ??? ???? ????? ?????? ???? ????? weight ??? ?????, ??? ????? node-app1 ???? ????????? ????? ????????????? ???? NGINX ?????? ???? ????????? ??????, ?????? ???????? (??? ????? ????????? weight ??????? ???????? ???)?

?????????? ?????? ??? ?????

??? ???? ??????????? localhost ?? ?? ????? ?????? GET request ??????, ??? ??? ??????????? ?????? NGINX ?????????? ????? NGINX ??? ????????????? ????????? Node.js ?????????????? ????? ?????? ?????? (????? weight ???????)? NGINX ???? ???? ????????? proxy ?? ??? ????? ??????????? ????????? nodejs container ? ?????????? ?? ?????? NGINX ?? ??????? ?????? ?

??? ??? ????? ???? ???? ????? ????? ????? ???? ?????? Docker ??? NGINX ??????? ??? ?????? Node.js ??????? ??? ??? ??? ??? ????? ????? ??? ????????? ??? ????

???? ??????? ?? ?????? ?????? ????? : https://github.com/Ruhulcse/basic_load_balancer

Thank you


Happy Coding


Hasanur Seam

Software Engineer | NodeJs | Angular | Java(Spring boot) | MongoDB | PostgreSQL | MSc Uni-Bremen

2 周

Nice effort

回复
Saeeda Akhter

IT consultant customer development

1 个月

Nice learning

Al Mahmud

Software Engineer | NodeJS | Nest.js | Docker | React | Angular | MongoDB | MySQL | Redis | Git

1 个月

Create a docker compose file. And just use docker compose up -d

Ashadujjman Hiru

DevOps | CKA | Ansible | AWS | Docker | Kubernetes | Jenkins | MySQL | PostgreSQL

1 个月

Great work

Sarwar Hossain

Software Developer [ Full Stack ]

1 个月

Effective!

要查看或添加评论,请登录