Traefik 网关入口
准备工作
创建网络用于 traefik 路由 docker 服务
| Bash |
|---|
| docker network create traefik --ipv6
|
创建配置文件
| traefik.yml |
|---|
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 | api:
insecure: true
dashboard: true
entryPoints:
web:
address: ":80"
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: ":443"
forwardedHeaders:
insecure: true
http:
tls:
certResolver: default
domains:
- main: "xxx.com"
sans:
- "*.xxx.com"
providers:
docker:
watch: true
network: traefik
exposedByDefault: false
endpoint: unix:///var/run/docker.sock
file:
watch: true
directory: /etc/traefik/config
certificatesResolvers:
default:
acme:
email: ******
storage: /etc/traefik/acme.json
dnsChallenge:
provider: cloudflare
|
配置文件
| docker-compose.yml |
|---|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | services:
traefik:
image: traefik
container_name: traefik
networks:
- traefik
ports:
- target: 80
published: 80
protocol: tcp
mode: host
- target: 443
published: 443
protocol: tcp
mode: host
volumes:
- ./data/traefik:/etc/traefik
- /var/run/docker.sock:/var/run/docker.sock
environment:
- CF_DNS_API_TOKEN=******
- CF_ZONE_API_TOKEN=******
- TZ=Asia/Shanghai
restart: always
|