Coder Social home page Coder Social logo

hab-nginx-lb's Introduction

Habitat nginx Load Balancer

This repository contains the Habitat plan source code for a dynamic nginx load balancer which binds to a service backend using the habitat supervisor.

Basic Usage

Start the service with the Habitat supervisor

$ hab start sethvargo/nginx-lb --bind backend:my-service.group

or Docker

$ docker run -p 80:80 sethvargo/nginx-lb --bind backend:my-service.group

In these examples, the backend is bound to the service named "my-service" in the group "group". If you do not specify a group when starting your service, it is bound to default (i.e. "my-service.default").

The backend binding is required, and the service will not start if there is not at least one upstream service to route to.

You may also need to specify the peer, especially if running under Docker:

$ docker run -p 80:80 sethvargo/nginx-lb \
    --peer 172.17.0.2 \
    --bind backend:my-service.group

Configuration

Please see default.toml for all available configurations. The most common are:

  • server_name - the FQDN to resolve requests for

  • http.port - the port to bind/listen on

  • http.balancing - the balancing algorithm to use for upstreams

Requirements

In order to be "flexible", the load balancer requires:

  • All backend services must expose a single port value. Other exposes are permitted, but nginx will bind to the exposed port on the service. Individual services can bind to different ports and ips - the load balancer will intelligently route.

  • Port 80 must be accessible. By default, this binds to a privileged port, so root or root-like privileges are required. It is possible to configure the service to bind on a non-privileged port (like 8080), by specifying http.port in the configuration. For example:

    $ export HAB_NGINX_LB="$(cat <<-EOF
    [http]
    port = 8080
    EOF
    )"
    $ hab start sethvargo/nginx-lb --bind ...

License

This Habitat plan is licensed under the MIT license. The nginx project and source code is licensed under BSD.

hab-nginx-lb's People

Contributors

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