Coder Social home page Coder Social logo

traefik-swarm's Introduction

traefik-swarm

Exemplo de Traefik como LB de swarm mode.

  1. Rodar traefik
docker network create --driver=overlay traefik-net
docker service create \
    --name traefik \
    --constraint=node.role==manager \
    --publish 8000:80 --publish 8080:8080 \
    --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
    --network traefik-net \
    traefik \
    --docker \
    --docker.swarmMode \
    --docker.domain=traefik \
    --docker.watch \
    --api

Na porta 8000 do host estará o traefik (erro 404 pois ainda não há app nenhuma na retaguarda) e na 8080 o dashboard.

  1. Rodar apps na retaguarda
# app 0
docker service create \
    --name whoami0 \
    --label traefik.port=80 \
    --network traefik-net \
    containous/whoami
# app 1
docker service create \
    --name whoami0 \
    --label traefik.port=80 \
    --network traefik-net \
    containous/whoami
# testando app 0
curl -H Host:whoami0.traefik localhost:8000
# testando app 1
curl -H Host:whoami1.traefik localhost:8000
  1. Testando regras de host e path (mesmo hostname, paths distintos)
docker service update \
    --label-add "traefik.frontend.rule=Host:whoami.aqui.com;PathPrefixStrip:/app0" \
    whoami0
docker service update \
    --label-add "traefik.frontend.rule=Host:whoami.aqui.com;PathPrefixStrip:/app1" \
    whoami1
curl -H Host:whoami.aqui.com localhost:8000/app0/
curl -H Host:whoami.aqui.com localhost:8000/app1/

traefik-swarm's People

Contributors

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