Coder Social home page Coder Social logo

nginx-node-lb's Introduction

Background

This is a sample repo I created for the express purpose of learning and becoming familiar with how to setup NGINX service in front of Node.js servers. Specifically in this particular case, I've configured NGINX as a reverse proxy and load balancer, load balancing 2 Node.js servers behind it.

Setup

  1. Install nginx on system by running brew install nginx
  2. Copy nginx.conf file in this repo to /usr/local/etc/nginx
  3. Run npm install in repo to install npm modules, mainly express
  4. Run npm start to start up Node server instances (server #1 on localhost:8080 and #2 on localhost:8081)
  5. Run brew services start nginx to startup the NGINX service at http://localhost:8080
  6. Open browser to http://localhost:8080 and refresh page a few times.

You should see a page with the message "Hello World from Node Server #1" or "Hello World from Node Server #2". This is effectively NGINX handling the request and proxying to the 2 Node servers using round-robin load balancing.

Resources

nginx-node-lb's People

Contributors

mbchoa avatar

Watchers

James Cloos avatar Huỳnh Trần Đăng Khoa avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.