Git Product home page Git Product logo

traefik's Introduction

INITIAL SETUP

  • Copy this folder to /etc so that you have the following layout:
/etc/traefik 
   |- bootstrap/
       |- dc-template.yml
       |- new.sh
       |- .env
   |- config/
       |- docker-compose.yml 
       |- dynamic/
           |- dynamic.yml
       |- traefik.yml
       |- .env
  • Next, you will want your certs available inside the dynamic directory (changes made to files in this directory are updated on save).

Setup

  • To be able to start from /etc/traefik, link the 3 files inside /etc/traefik/config/ one directory up.
  • Your dynamic directory should not watch /etc/traefik/ (configured in traefik.yml under providers.file.directory) or else you will duplicate all of your container volumes.
  • Only Traefik should have the additional port declaration or (depending on how you decide to lay it out) the additional subdirectory /config
  • Ensure the path / name of your certs in /etc/traefik/config/dynamic/ are listed correctly inside /etc/traefik/config/dynamic/dynamic.yml
  • Create the traefik network: docker network create traefik.
  • Set your ENV's in /etc/traefik/config/.env

Start Traefik

cd /etc/traefik
docker compose up -d
docker logs traefik
  • Doulbe check for any config errors.
  • Try visiting http://service.domain.name - it should redirect you to https and show trusted certs

Start a New Proxied Service

If you already have a service defined in a docker-compose.yml, you can just copy the labels section of /etc/traefik/bootstrap/dc-template.yml into your file and either make replacements directly or use the .env file in the same directory.

  • To bootstrap a service, you can read the script in bootstrap/new.sh or get the TL;DR with:
/etc/traefik/bootstrap/new.sh --help
  • I personally linked this as a binary, so I can run the script as traefik
ln -s /etc/traefik/bootstrap/new.sh /usr/local/bin/traefik
  • Example:
traefik -s 'homebridge' -i 'onzu/homebridge:latest' -p '8581' -h 'hb' -r 'home' -d 'domain.name'
  • Only -s, -i, and -p are required. -h is interpreted, and -d can be set in /etc/traefik/bootstrap/.env.
  • New services will get their own directory in /etc/traefik/<service>/
  • You will have to manually configure / customize the docker-compose.yml for any additional ports / mounts / volumes you need.

Poxy an existing service on the host machine

See /etc/traefik/config/dynamic/dynamic.yml for an example of this configuration. There you can define hhtp routers, middlewares, and services to proxy local ports through traefik. Make sure your hosts file / DNS server includes the records you want proxied.

Example Directory Structure

/etc/traefik 
    |- bootstrap/
        |- dc-template.yml
        |- new.sh
        |- .env
    |- homebridge/
        |- docker-compose.yml
        |- .env
    |- plex/
        |- config/
        |- media/
        |- transcode/
        |- docker-compose.yml
        |- .env
    |- config/
        |- docker-compose.yml 
        |- dynamic/
            |- fullchain.pem
            |- privkey.pem
            |- dynamic.yml
        |- traefik.yml
        |- .env
    |- docker-compose.yml => config/docker-compose.yml
    |- traefik.yml => config/traefik.yml
    |- .env => config/.env

Useful aliases

echo "alias dcud='docker compose up -d'" >> ~/.bashrc
echo "alias dcd='docker compose down'" >> ~/.bashrc
echo "alias dcr='dcd && dcud'" >> ~/.bashrc
echo "alias dlt='docker logs traefik'" >> ~/.bashrc

traefik's People

Contributors

tj-smith47 avatar

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.