gpt4 book ai didi

https - 为什么 Traefik 2.0 不检测我指定的默认静态证书,而是自己生成一个?

转载 作者:行者123 更新时间:2023-12-04 01:38:02 25 4
gpt4 key购买 nike

在我最初尝试将基于 docker-swarm 的 Traefik 安装从 1.7 迁移到 2.0 时,我发现我的 traefik.toml 配置文件中默认静态指定的 SSL 配置被忽略了,并且在启用调试的情况下,我的 docker 日志显示了许多类似的消息:

time="2019-11-06T20:26:30Z" level=debug msg="No default certificate, generating one"

最佳答案

事实证明,Traefik 2.0 SSL 配置总是被视为动态的(仔细阅读 here ),因此必须定义一个动态文件提供程序(参见 here ),而且这个动态配置必须在一个文件与主 Traefik 配置文件分开。

如果尝试简化此过程,并将主 traefik 配置文件声明为动态文件提供程序,则可能会在日志中看到以下无用消息:

time="2019-11-06T20:26:30Z" level=error msg="Cannot start the provider *file.Provider: template: :179:35: executing \"\" at <.Name>: can't evaluate field Name in type bool"

一旦正确配置消息将显示如下:

time="2019-11-06T20:45:20Z" level=debug msg="Configuration received from provider file: {\"http\":{},\"tcp\":{},\"tls\":{\"stores\":{\"default\":{\"defaultCertificate\":{\"certFile\":\"/etc/certs/server.crt\",\"keyFile\":\"/etc/certs/server.key\"}}}}}" providerName=file

Containous 社区论坛(例如 here )和 Reddit(例如 here )上的几篇帖子肯定有助于解决这里问题,但希望此摘要也能有所帮助。

以下 docker-compose.yml(手动编辑以删除一些抽象,例如位置限制、网络、我们自己的身份验证等)在这一点上几乎可以在 docker swarm 上将 Traefik 作为扩展的 docker 服务运行,使用仪表板已启用并位于 https 之后。本例中的 Traefik 标签位于 Traefik 服务本身,并为在 8080 上运行的仪表板设置路由器和“后端”服务。

version: '3.3'
secrets:
rsa_private_key:
file: key.pem
rsa_cert:
file: crt.pem
configs:
toml_conf:
file: traefik.toml
dynamic_toml_conf:
file: dynamic_conf.toml
services:
svc:
# The official v2.0 Traefik docker image
image: traefik:v2.0.2
# Enables the web UI and tells Traefik to listen to docker
ports:
# Primary inbound HTTPS traffic.
- "443:443"
# HTTP traffic open for the purposes of permanent redirect to HTTPS.
- "80:80"
deploy:
replicas: 3
restart_policy:
condition: on-failure
max_attempts: 3
delay: 30s
window: 60s
labels:
- "traefik.enable=true"
- "traefik.http.routers.api-sec.entrypoints=websecure"
- "traefik.http.routers.api-sec.tls=true"
- "traefik.http.routers.api-sec.tls.options=default"
- "traefik.http.routers.api-sec.rule=Host(`myhost`)"
- "traefik.http.routers.api-sec.service=api@internal"
# Now the backend service...
- "traefik.http.services.api.loadbalancer.server.port=8080"
secrets:
- source: rsa_private_key
target: /etc/certs/server.key
- source: rsa_cert
target: /etc/certs/server.crt
configs:
- source: toml_conf
target: /etc/traefik/traefik.toml
- source: dynamic_toml_conf
target: /etc/dynamic_conf.toml
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock

关于https - 为什么 Traefik 2.0 不检测我指定的默认静态证书,而是自己生成一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58738864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com