-
Notifications
You must be signed in to change notification settings - Fork 8
/
docker-compose.yaml
61 lines (52 loc) · 2.69 KB
/
docker-compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# compose spec doesn't need a version anymore,
# see https://github.com/compose-spec/compose-spec/blob/master/spec.md
services:
# traefik container
traefik:
image: traefik:v3.0.0-beta2 # still in beta, use v2.9.6 for stable version
# please check version tag to use the most current version
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro # It's not recommended mounting the docker socket into a container -> see https://github.com/wollomatic/traefik2-hardened
- ./config/traefik.yaml:/etc/traefik/traefik.yaml:ro # static traefik configuration
- ./config/dynamic.yaml:/etc/traefik/dynamic.yaml:ro # dynamic traefik configuration
- ./config/acme.json:/etc/traefik/acme.json # TLS certificate storage
labels:
- "traefik.enable=true"
# define basic auth middleware for dashboard
- "traefik.http.middlewares.traefik-auth.basicauth.removeheader=true"
- "traefik.http.middlewares.traefik-auth.basicauth.users=foobar:$$2y$$05$$z2KwKI.GmZ43BbwfmPPKw.CSl3rqQ0OhzBbdom.orfsMVKGLW/Xeu" # CHANGE PASSWORD!! (user: foobar / pwd: foobar)
# how to set a real password:
# sudo apt-get install apache2-utils
# htpasswd -Bnb username password | sed -e s/\\$/\\$\\$/g
# define traefik dashboard router and service
- "traefik.http.routers.traefik.rule=Host(`foobar.example.invalid`)" # change hostname!
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.tls.certresolver=tlschallenge"
- "traefik.http.routers.traefik.entrypoints=web-secure"
- "traefik.http.routers.traefik.middlewares=traefik-auth, secHeaders@file, autodetectContenttype@file"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
networks:
- traefik-servicenet
ports:
- "80:80"
- "443:443"
# whoami example container
whoami:
image: traefik/whoami:latest
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.entrypoints=web-secure"
- "traefik.http.routers.whoami.rule=Host(`whoami.example.invalid`)" # change hostname!
- "traefik.http.routers.whoami.tls=true"
- "traefik.http.routers.whoami.tls.certresolver=tlschallenge"
- "traefik.http.routers.whoami.middlewares=secHeaders@file"
- "traefik.http.services.whoami.loadbalancer.server.port=80" # set port the container listenes to
networks:
- traefik-servicenet
networks:
traefik-servicenet:
external: true
name: traefik-servicenet # create this network before running this deployment:
# docker network create traefik-servicenet