Nginx-App
A Hello World Node.js app with nginx load balancing
Basic setup required for project to run:
Installations:
- Node.js [https://nodejs.org/en/]
- Express (Web framework for Node.js) [https://expressjs.com/]
- PM2 (Node.js process manager) [http://pm2.keymetrics.io/]
- Nginx [http://nginx.org/en/docs/windows.html]
Steps to run the project
- Go into the folder where
pm2.json
exists. Run the following command:pm2 start pm2.json
This starts the multiple instances of the app on different ports provided as arguments. - Go to the folder that contains
nginx.exe
and run the following command on the terminal:start nginx
. You can check if nginx is running using the following command:tasklist /fi “imagename eq nginx.exe”
- Open a web browser and go to localhost. The first output will be Hello World from localhost:4001. On every refresh of the page the port will change showing that the requests are being load balanced over the three servers specified in the nginx.conf file.