Giter Site home page Giter Site logo

docker-traefik's Introduction

๐Ÿ‹ Docker ๐Ÿ Traefik ๐Ÿฆ„ .Localhost

Use Traefik to proxy Docker containers for *.localhost development. Assuming *.localhost domains resolve to the loopback interface.

Now updated to provided HTTPS for a custom domain.

Usage

Create a bridge network named traefik:

docker network create -d bridge traefik

Create an .env file (chmod 600):

TRFK_HOST_IP=127.0.0.1
TRFK_HTTP_PORT=80
TRFK_HTTPS_PORT=443
TRFK_ACME_DOMAIN=example.dev
[email protected]
TRFK_ACME_PROVIDER=cloudflare
TRFK_ACME_RESOLVER="1.1.1.1:53"
CF_DNS_API_TOKEN="see: https://go-acme.github.io/lego/dns/cloudflare/"

Start the Traefik container (this repo):

docker-compose up -d

Discovery

Traefik will automatically discover containers in the traefik network that use labels. See docker-compose.yml for the full example service.

Insecure .localhost domain:

labels:
  - "traefik.enable=true"
  - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
  - "traefik.http.services.whoami.loadbalancer.server.port=80"

Secure domain:

labels:
  - "traefik.enable=true"
  - "traefik.http.routers.whoami.entrypoints=websecure"
  - "traefik.http.routers.whoami.rule=Host(`whoami.${TRFK_ACME_DOMAIN}`)"
  - "traefik.http.services.whoami.loadbalancer.server.port=80"

Or via the dynamic.yml config file:

http:
  routers:
    whoami:
      entryPoints: ['websecure']
      rule: "Host(`whoami.{{ env "TRFK_ACME_DOMAIN" }}`)"
      service: whoami
  services:
    whoami:
      loadBalancer:
        servers:
          - url: "http://whoami"

See the Traefik documentation for more details.


MIT License | Copyright ยฉ 2023 David Bushell | @dbushell

docker-traefik's People

Contributors

dbushell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mn-ahmed eosbot

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.