Added traefik Example

pull/130/head
Chris Chase 2020-07-29 14:02:02 +09:30
parent 229fb903cd
commit dc28220e88
3 changed files with 83 additions and 0 deletions

26
traefik-example/README.md Normal file
View File

@ -0,0 +1,26 @@
Crontab UI - Traefik Example
==========
*Traefik is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy.*
https://containo.us/traefik/
## Running Example
Assumes port 88 and 8088 are free.
1. `docker-compose build`
2. `docker-compose up`
Then go to
- http://127.0.0.1:88/crontab to view contrab-ui
- http://127.0.0.1:88/whoami another docker container (containous/whoami) running on another path.
- http://127.0.0.1:8088/dashboard/ to view the Traefik dashbaord.

View File

@ -0,0 +1,43 @@
version: '3.7'
networks:
traefik_network:
services:
proxy:
image: traefik:v2.2
container_name: proxy
restart: unless-stopped
networks:
- traefik_network
ports:
- 88:80
- 8088:8080
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.yml:/etc/traefik/traefik.yml
command:
- "--providers.docker"
whoami:
image: containous/whoami
networks:
- traefik_network
labels:
- traefik.enable=true
- traefik.http.routers.whoami.rule=PathPrefix(`/whoami`)
crontab-ui:
build: ..
image: alseambusher/crontab-ui
ports:
- 8000:8000
networks:
- traefik_network
labels:
- traefik.enable=true
- traefik.http.routers.crontab.rule=PathPrefix(`/crontab`)
environment:
BASE_URL: /crontab
BASIC_AUTH_USER: user
BASIC_AUTH_PWD: pass

View File

@ -0,0 +1,14 @@
## traefik.yml
# Docker configuration backend
providers:
docker:
# defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
endpoint: "unix:///var/run/docker.sock"
# swarmMode: true
network: traefik_network
exposedbydefault: false
# API and dashboard configuration
api:
insecure: true