我正在尝试使用traeffik设置letsEncrypt,无论我做什么它似乎都不起作用。目前我收到以下错误:
其他SO帖子提到这可能是由于没有使用traeffik(Traefik will issue certificate instead of Let's encrypt)的http挑战,但我正在使用它,所以我不知道诚实(这不解决问题 - 不要关闭)。我的配置文件似乎很小,但我没有收到任何错误反馈,因此我在休息时迭代的能力很小。如果有人能就如何解决这个问题提供任何帮助我会很感激 - 我已经有一段时间了,我不知道该做什么。
我使用这个小的bash脚本调出下面的三个文件:
root@ubuntu-1gb-nyc3-01:/lowteck# cat ./runSwarm.sh
#!/bin/bash
./buildandpush.sh
cd ./back
./buildandpush.sh
cd ..
docker volume prune -f
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker swarm init \
--advertise-addr 104.236.214.151
docker network create -d overlay --attachable proxy
docker stack deploy --compose-file=stage.yaml prod2
docker stack deploy --compose-file=traefik.yaml prodTraefik
这是我的traefik.toml
:
root@ubuntu-1gb-nyc3-01:/lowteck# cat traefik.toml
logLevel = "DEBUG"
defaultEntryPoints = ["http", "https"]
[web]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.forwardedHeaders]
trustedIPs = ["104.236.214.151"]
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[acme]
caServer = "https://acme-v02.api.letsencrypt.org/directory"
email = "[email protected]"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"
[[acme.domains]]
main = "lowteck.com"
sans = ["www.lowteck.com"]
[docker]
domain = "traefik"
watch = true
swarmmode = true
network="web"
这是我的traefik.yaml
:
root@ubuntu-1gb-nyc3-01:/lowteck# cat traefik.yaml
version: '3.3'
networks:
proxy:
external: true
configs:
traefik.toml:
file: ./traefik.toml
services:
traefik:
image: traefik
ports:
- "80:80"
- "8080:8080"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
configs:
- source: traefik.toml
target: /etc/traefik/traefik.toml
labels:
- "traefik.enable=false"
networks:
- proxy
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
这是我的stage.yaml
:
root@ubuntu-1gb-nyc3-01:/lowteck# cat stage.yaml
version: "3.3"
networks:
default:
external: false
proxy:
external: true
services:
back:
image: patientplatypus/lowtechback:latest
ports:
- '5000:5000'
networks:
- proxy
- default
deploy:
replicas: 1
restart_policy:
condition: on-failure
max_attempts: 5
window: 120s
labels:
- "traefik.docker.backend=back"
- "traefik.port=5000"
- "traefik.frontend.rule=Host:back.lowteck.com"
- "traefik.docker.network=proxy"
front:
image: patientplatypus/lowtechfront:latest
ports:
- '3000:3000'
networks:
- proxy
- default
depends_on:
- back
deploy:
replicas: 1
restart_policy:
condition: on-failure
max_attempts: 5
window: 120s
labels:
- "traefik.docker.backend=front"
- "traefik.port=3000"
- "traefik.frontend.rule=Host:104.236.214.151, lowteck.com, www.lowteck.com, zennify.me"
- "traefik.docker.network=proxy"
再一次,我已经有一段时间了,我基本上没有错误代码可以继续。如果有人有任何建议,请告诉我。
编辑:
我在登出traefik pod后发现了一个错误 - 即我需要:
[[acme.domains]]
main = "lowteck.com"
sans = ["www.lowteck.com", "back.lowteck.com"]
然而,这并没有解决https问题,尽管traefik容器的日志现在已经清楚了。你可以在这里看到完整的日志输出:https://gist.github.com/patientplatypus/8a40e12c6ba64cdc7d2bf88581967057。
所以我终于得到了解决,并且有一些事情有助于我想指出任何碰到这个的人。
1)您应该使用docker service logs YOURTRAEFFICPOD
记录您的traefik pod以获取任何和所有错误进行调试。出于某种原因,我没有想到这一点(愚蠢)。
2)acme sans部分不是由pod定义的,而是由域的A记录中的内容定义的。如果它不在A记录中,则不将其放在那里 - 这将在日志中显示为错误。
3)确保您使用的是最新版本的traefik - 在我的情况下,我必须通过更改traefik.toml
将线路image: traefik:v1.7.9
更改为trafik版本为1.7.9
4)如果你正在使用http挑战你的acme.json文件将是,应该是空的 - 所以不要担心这一点。
5)最后,如果您从letsEncrypt收到错误消息,表明您已经超过了域名的最大证书申请数量,这实际上可能不会强制您的域名没有https - 您应该检查它仍然可以使用以前的证书。
就是这样,感谢所有人的帮助!