Coder Social home page Coder Social logo

traefik-lb's Introduction

Traefik LoadBalancer

This project sets up a Traefik load balancer in order to serve other projects through it.

  • Load balancer: https://traefik.josep.co

Run: make to see available Makefile targets.

Available targets:

  docker/restart                      Restart base stack resources
  docker/start                        Start base stack resources
  docker/stop                         Stop base stack resources
  ...
  start                               Start base stack resources. Alias for: docker/start
  stop                                Stop base stack resources. Alias for: docker/stop

Before start

Generate SSL certificates

make ssl/josep

Hosts file

You need to add an entry for the Traefik home page and then as many entries as projects that you have, each with its own subdomain. Like in the second line.

127.0.0.1 traefik.josep.co
127.0.0.1 myproject.josep.co

Run

make start

Configure other projects to be served through the load balancer

Having a project with name: my-flask-app that is served through port 5000.

Add it to the hosts file

127.0.0.1 traefik.josep.co
127.0.0.1 my-flask-app.josep.co

Importing and connecting from the other projects

Example of docker-compose. Pay attention especially to the following sections:

  • lb_net network so that they are in the same local network.
  • Traefik labels to make the service discoverable by Traefik and add the configuration.

Example of docker-compose

version: "3.9"
services:
  web:
    build: .
    env_file:
      - .env
    ports:
      - "6000:5000"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.my-flask-app.entrypoints=websecure"
      - "traefik.http.routers.my-flask-app.tls=true"
      - "traefik.http.routers.my-flask-app.rule=Host(`my-flask-app.josep.co`)"
      - "traefik.http.routers.my-flask-app.service=my-flask-app"
      - "traefik.http.services.my-flask-app.loadbalancer.server.port=5000"
    networks:
      - lb_net

networks:
  lb_net:
    external: true

Now you can access https://my-flask-app.josep.co

traefik-lb's People

Watchers

 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.