-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.traefik.yml
More file actions
81 lines (68 loc) · 3.21 KB
/
docker-compose.traefik.yml
File metadata and controls
81 lines (68 loc) · 3.21 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
services:
traefik:
image: traefik:3.0
ports:
# Listen on port 80, default for HTTP, necessary to redirect to HTTPS
- 80:80
# Listen on port 443, default for HTTPS
- 443:443
env_file:
- .traefik_env
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_REGION=${AWS_REGION}
restart: always
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.http.services.traefik-dashboard.loadbalancer.server.port=8080
# HTTP to HTTPS redirection middleware
- traefik.http.middlewares.https-redirect.redirectscheme.scheme=https
- traefik.http.middlewares.https-redirect.redirectscheme.permanent=true
- traefik.http.middlewares.rate-limit-10.ratelimit.average=10
# HTTP Router (with middleware to redirect to HTTPS)
- traefik.http.routers.traefik-dashboard-http.entrypoints=http
- traefik.http.routers.traefik-dashboard-http.rule=Host(`traefik.${DOMAIN?Variable not set}`)
- traefik.http.routers.traefik-dashboard-http.middlewares=https-redirect
# Authentication to access traefik dashboard middleware
- traefik.http.middlewares.admin-auth.basicauth.users=${USERNAME?Variable not set}:${HASHED_PASSWORD?Variable not set}
# HTTPS Router
- traefik.http.routers.traefik-dashboard-https.entrypoints=https
- traefik.http.routers.traefik-dashboard-https.rule=Host(`traefik.${DOMAIN?Variable not set}`)
- traefik.http.routers.traefik-dashboard-https.tls=true
- traefik.http.routers.traefik-dashboard-https.tls.certresolver=myresolver
- traefik.http.routers.traefik-dashboard-https.middlewares=admin-auth,rate-limit-10
# Use the special Traefik service api@internal with the web UI/Dashboard
- traefik.http.routers.traefik-dashboard-https.service=api@internal
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-public-certificates:/certificates
command:
# Enable docker and not to expose it public
- --providers.docker
- --providers.docker.exposedbydefault=false
# Entrypoints
- --entrypoints.http.address=:80
- --entrypoints.https.address=:443
# Enable myresolver DNS challange, let's encrypt cert
- --certificatesresolvers.myresolver.acme.dnschallenge=true
- --certificatesresolvers.myresolver.acme.dnschallenge.provider=route53
- --certificatesresolvers.myresolver.acme.email=${EMAIL?Variable not set}
- --certificatesresolvers.myresolver.acme.storage=/certificates/acme.json
# Enable the access log, with HTTP requests, Traefik log and Dashboard API
- --accesslog
- --log
- --api
networks:
# Use the public network created to be shared between Traefik and
# any other service that needs to be publicly available with HTTPS
- traefik-public
volumes:
# Create a volume to store the certificates, even if the container is recreated
traefik-public-certificates:
networks:
# Use the previously created public network "traefik-public", shared with other
# services that need to be publicly available via this Traefik
traefik-public:
external: true