Giter Club home page Giter Club logo

docker-traefik's Introduction

docker-traefik

This repository is a demonstration on how to setup Traefik as just a basic container service or in Docker Swarm Mode to automate HTTPS via Let's Encrypt. There are a number of other configurations you can do with this, but I tried to keep this simple. For other configuration options, take a look at Traefik's Documentation.

What is Traefik?

A reverse proxy / load balancer that's easy, dynamic, automatic, fast, full-featured, open source, production proven, provides metrics, and integrates with every major cluster technology... No wonder it's so popular!

Traefik

How to use this repository

First, you will need to clone the repository locally:

$ git clone https://github.com/BashfulBandit/docker-traefik.git

Now you will just need to run the start.sh BASH script.

$ bash bin/start.sh

This will take you through the process of determining if you are wanting to run this in Docker Swarm Mode or just as a single Docker Container. It will also set up the proper environment variables for you and store them in the .env file. See Environment Variables section for me details.

How to stop the service?

If you have previous run the start.sh script, you can easily stop everything by running the command below.

$ bash bin/stop.sh

How to setup another service behind your Traefik Docker Service.

If you want to setup a Docker service behind Traefik, which I am assuming that is your main goal for setting this up. You will need to configure the docker-compose file or your docker run script for the service to have Traefik recognize it. There are two main requirements for Traefik to be able to recognize the service and to be able to communicate with the service.

  • The Docker Service will need to be a part of the same Docker Network Traefik is a part of. The easiest way to do this is by attaching your Docker Service to the 'proxy-net' Docker Network made for Traefik. This can be done a number of different ways. See the example directory in this repository for one way.
  • The Docker Service will need some labels defined for Traefik to know how to handle requests to this service. Here are the main labels needed. See the example directory in this repository for an example.
    • traefik.frontend.rule
    • traefik.docker.network
    • traefik.port
    • traefik.enable

Environment Variables

All these environment variables will be configured the first time you run the start.sh script, but you can manually configure them in your .env file.

DOCKER_START_COMMAND

This is the command used to start the Traefik Docker Service.

DOCKER_STOP_COMMAND

This is the command used to stop the Traefik Docker Service.

COMPOSE_FILE

This is the compose file used when starting and stopping your Traefik Docker Service.

SERVICE_NAME

This is either the name of your Docker Swarm Stack or the Docker Container based on what environment you are running.

DOMAIN

The name of your domain you want Traefik to proxy for. For this use case, it is just being used for the Dashboard service of Traefik itself at traefik.$DOMAIN. This requires your DNS be set up to send traefik.$DOMAIN to your IP address.

EMAIL

The email address used for the ACME Challenge.

Report an Issue

If you have any issues with this repository and it's functionality, check out if there is already a GitHub issue submitted and if not, feel free to submit one here.

Resources

  • Docker - a computer program that performs operating-system-level virtualization, also known as "containerization".
  • Traefik - a reverse proxy / load balancer that's easy, dynamic, automatic, fast, full-featured, open source, production proven, provides metrics, and integrates with every major cluster technology.
  • Let's Encrypt - a certificate authority that provides X.509 certificates for Transport Layer Security (TLS) encryption at no charge.

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.