Skip to content

Commit b8790a6

Browse files
committed
[traefik] simpify traefik config
1 parent 08af48f commit b8790a6

File tree

5 files changed

+115
-136
lines changed

5 files changed

+115
-136
lines changed

Diff for: traefik/conf/bensonfx.yml

-72
This file was deleted.

Diff for: traefik/conf/tls.yml renamed to traefik/conf/default.yml

+32-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1+
http:
2+
middlewares:
3+
https-redirect:
4+
redirectScheme:
5+
scheme: https
6+
permanent: false
7+
port: 5443
8+
content-compress:
9+
compress: {}
10+
11+
services:
12+
# tricks https://github.com/containous/traefik/issues/4863#issuecomment-491093096
13+
dummy:
14+
loadBalancer:
15+
servers:
16+
- url: "" # or url: "localhost"
17+
18+
routers:
19+
https-redirect:
20+
entryPoints:
21+
- http
22+
rule: "HostRegexp(`{any:.*}`)"
23+
service: "dummy"
24+
middlewares:
25+
- "https-redirect"
26+
127
tls:
2-
certificates:
3-
- certFile: /data/ssl/example.com.crt
4-
keyFile: /data/ssl/example.com.key
5-
stores:
6-
- default
28+
# certificates:
29+
# - certFile: /data/ssl/example.com.crt
30+
# keyFile: /data/ssl/example.com.key
31+
# stores:
32+
# - default
733
options:
834
default:
935
minVersion: VersionTLS12
@@ -24,3 +50,4 @@ tls:
2450
- TLS_RSA_WITH_AES_256_GCM_SHA384
2551
- TLS_RSA_WITH_AES_128_CBC_SHA
2652
- TLS_RSA_WITH_AES_256_CBC_SHA
53+

Diff for: traefik/conf/nas.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
http:
2+
services:
3+
dsphoto:
4+
loadBalancer:
5+
servers:
6+
- url: "http://photo.example.com"
7+
nas:
8+
loadBalancer:
9+
servers:
10+
- url: "http://nas.example.com:5000"
11+
routers:
12+
dsphoto:
13+
entryPoints:
14+
- https
15+
service: dsphoto
16+
rule: "Host(`photo.example.com`)"
17+
tls: {}
18+
nas:
19+
entryPoints:
20+
- https
21+
service: nas
22+
rule: "Host(`www.example.com`)"
23+
tls:
24+
certResolver: le
25+
domains:
26+
- main: "*.example.com"
27+
sans:
28+
- "example.com"
29+
- "*.example.com"

Diff for: traefik/docker-compose.yml

+54-6
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,77 @@ services:
33
traefik:
44
container_name: traefik-v2
55
image: traefik:v2.3
6-
command: traefik --configFile /etc/traefik.yml
76
restart: unless-stopped
87
healthcheck:
98
test: ["CMD-SHELL", "wget -q --spider localhost:8080/ping || exit 1"]
10-
command: traefik --configFile /etc/traefik.yml
9+
command:
10+
- "--global.sendanonymoususage=false"
11+
- "--global.checknewversion=false"
12+
- "--api.dashboard=true"
13+
# - "--api.debug=true"
14+
- "--ping=true"
15+
- "--entrypoints.http.address=:80"
16+
- "--entrypoints.https.address=:443"
17+
- "--entryPoints.web.forwardedHeaders.trustedIPs=172.18.0.0/24,192.168.31.0/24"
18+
- "--log.level=WARN"
19+
- "--log.filePath=/logs/traefik.log"
20+
- "--log.format=json"
21+
- "--accesslog.filepath=/logs/access.log"
22+
- "--accesslog.format=json"
23+
- "--providers.docker=true"
24+
- "--providers.docker.watch=true"
25+
- "--providers.docker.exposedbydefault=false"
26+
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
27+
- "--providers.docker.useBindPortIP=false"
28+
- "--providers.docker.network=traefik"
29+
- "--providers.docker.swarmMode=false"
30+
- "--providers.file=true"
31+
- "--providers.file.directory=/etc/traefik/conf"
32+
- "--providers.file.debugloggeneratedtemplate=true"
33+
34+
- "--certificatesresolvers.le.acme.storage=/data/ssl/acme.json"
35+
- "--certificatesresolvers.le.acme.keytype=EC256"
36+
- "--certificatesresolvers.le.acme.dnschallenge=true"
37+
- "--certificatesresolvers.le.acme.dnschallenge.provider=cloudflare"
38+
- "--certificatesresolvers.le.acme.dnschallenge.delaybeforecheck=15"
39+
- "--certificatesresolvers.le.acme.dnschallenge.resolvers=1.1.1.1:53,8.8.8.8:53"
1140
environment:
1241
TZ: "Asia/Shanghai"
1342
CF_API_EMAIL: ${CF_API_EMAIL}
1443
CF_DNS_API_TOKEN: ${CF_DNS_API_TOKEN}
1544
CF_ZONE_API_TOKEN: ${CF_ZONE_API_TOKEN}
1645
volumes:
1746
- /etc/localtime:/etc/localtime:ro
47+
- /etc/timezone:/etc/timezone:ro
1848
- /var/run/docker.sock:/var/run/docker.sock:ro
1949
- ./traefik.yml:/etc/traefik.yml:ro
2050
- ./conf:/etc/traefik/conf:ro
2151
- ./ssl:/data/ssl
2252
- ./logs:/logs
2353
ports:
24-
- "80:80"
25-
- "443:443"
54+
- "80:80"
55+
- "443:443"
2656
labels:
27-
- "traefik.docker.network=traefik"
28-
- "traefik.http.routers.traefik.service=api@internal"
57+
- "traefik.enable=true"
58+
- "traefik.docker.network=traefik"
59+
- "traefik.http.routers.traefik.service=api@internal"
60+
# 默认请求转发 https 端口
61+
- "traefik.http.routers.traefik-dash-default.middlewares=https-redirect@file"
62+
- "traefik.http.routers.traefik-dash-default.entrypoints=http"
63+
- "traefik.http.routers.traefik-dash-default.rule=Host(`admin.example.com`)"
64+
- "traefik.http.routers.traefik-dash.service=dashboard@internal"
65+
# 处理网页
66+
- "traefik.http.middlewares.basic-auth.basicauth.users=$AUTH_USER_LIST"
67+
- "traefik.http.routers.traefik-dash-web.middlewares=basic-auth"
68+
- "traefik.http.routers.traefik-dash-web.entrypoints=https"
69+
- "traefik.http.routers.traefik-dash-web.rule=Host(`admin.example.com`) && PathPrefix(`/`)"
70+
- "traefik.http.routers.traefik-dash-web.tls=true"
71+
- "traefik.http.routers.traefik-dash-web.service=dashboard@internal"
72+
# 处理接口
73+
- "traefik.http.routers.traefik-dash-api.entrypoints=https"
74+
- "traefik.http.routers.traefik-dash-api.rule=Host(`admin.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
75+
- "traefik.http.routers.traefik-dash-api.tls=true"
76+
- "traefik.http.routers.traefik-dash-api.service=api@internal"
2977
networks:
3078
- "traefik"
3179
# ldap:

Diff for: traefik/traefik.yml

-53
This file was deleted.

0 commit comments

Comments
 (0)