Code Monkey home page Code Monkey logo

tcp-load-balancer's Introduction

TCP Load Balancer

Description

This project implements TCP Load Balancer with keepalived and nginx. The setup is as follows:

graph LR
  user -->|ports 80 & 443| vip;
  ng1 --- t1;
  ng1 --- t2;
  ng1 --- t3;
  
  subgraph " "
    subgraph load-balancer-1
      vip((vip)) -.- ng1(nginx)
      kl1(keepalived) --- |"health check: localhost:8080/nginx-status"| ng1 
    end
    subgraph load-balancer-2
      kl2(keepalived) --- ng2(nginx)
    end
  end
  subgraph " "
    subgraph Upstream
      t1(Target-1)  
      t2(Target-2)  
      t3(Target-3)  
    end
  end
Loading

There can be any number of load balancer and upstream servers. Both keepalived and nginx are un in containers with docker-compose.

Installation

Clone this repo to each load balancer server and modify configuration as desribed below.

Pre-requisites

  1. At least two servers with:
    • docker
    • docker-compose
    • ports 80 and 443 open
  2. VIP address

Configure keepalived

  1. Copy env-template to .env and edit parameter values in the new .env file if needed.
  2. Make sure check-status.sh is executable: chmod +x check-status.sh

Configure nginx

Edit target server addresses to following blocks in nginx.conf:

  • upsteam_443
  • upstream_80

Operation

Start-up

docker-compose up -d

Stop

docker-compose down

tcp-load-balancer's People

Contributors

hamedfarv avatar

Watchers

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