0%

在Traefik中配置Let's Encrypt

关于Traefik,参考我的另一篇文章:使用Docker部署Traefik服务

本文使用alidns,需要先申请ALICLOUD_ACCESS_KEYALICLOUD_SECRET_KEY

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
version: '3.7'

services:
traefik:
image: traefik
restart: always
labels:
- traefik.http.routers.traefik.rule=Host(`traefik.yourdomain.com`)
- traefik.http.routers.traefik.entrypoints=websecure
- traefik.http.routers.traefik.service=traefik
- traefik.http.services.traefik.loadbalancer.server.port=8080
command:
- --providers.docker
- --api.dashboard=true
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.websecure.address=:443
- --entrypoints.websecure.http.tls.certResolver=letsencrypt
- --certificatesResolvers.letsencrypt.acme.storage=/certs/acme.json
- --certificatesResolvers.letsencrypt.acme.dnsChallenge.provider=alidns
environment:
- ALICLOUD_ACCESS_KEY=xxx
- ALICLOUD_SECRET_KEY=xxx
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- certs:/certs

volumes:
certs:

更多provider参考:https://doc.traefik.io/traefik/https/acme/#providers