Traefik配置示例混合让我们加密和购买的证书

时间:2018-03-24 20:37:54

标签: docker lets-encrypt traefik

对于Traefik,我想使用Let的加密仅用于一些新的特定前端主机规则,因为我已经在一些现有的前端主机规则中使用了购买的证书。这是我现有的工作示例traefik.toml,没有Let的加密[acme]配置:

defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]
      [[entryPoints.https.tls.certificates]]
      certFile = "/etc/traefik/certs/myhost.tld.crt"
      keyFile = "/etc/traefik/certs/myhost.tld.key"

从我所阅读的内容here OnHostRule = true适用于所有主机规则。

是否有示例Traefik配置显示如何对特定主机使用Let?加密,而不是使用已购买证书的主机?

2 个答案:

答案 0 :(得分:1)

您可以将HTTPS与SNI(服务器名称指示)一起使用,以将特定SSL证书分配给特定域或子域。

您可以从下面的官方文档链接中找到HTTPS + SNI配置的示例。

https://docs.traefik.io/user-guide/examples/#http-https-with-sni

编辑1:

  

是否有示例Traefik配置显示如何对特定主机使用Let的加密,而不是使用已购买的证书的主机?

您可以尝试官方文档的this section中的示例。它表示只会为所提供的证书无法检查的域生成let加密证书。

您也可以参考this link了解ACME允许加密配置的每个配置项的说明。

希望这有帮助。

答案 1 :(得分:1)

说您的目录和文件结构如下。

 traefik
 |-ssl
   |-ca.key
   |-ca_chain.crt
 |-traefik.toml
 |-acme.json

更新您的traefik.toml

#traefik.toml

debug = true

defaultEntryPoints = ["http", "https"]

# Force HTTPS
[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]
     [[entryPoints.https.tls.certificates]]
      certFile = "/etc/traefik/ssl/ca_chain.crt"
      keyFile = "/etc/traefik/ssl/ca.key"


# Let's encrypt configuration
[acme]
email = "email@domain.com" #any email id will work
storage="/etc/traefik/acme.json"
entryPoint = "https"
acmeLogging=true
onHostRule = true
[acme.httpChallenge]
  entryPoint = "http"

创建acme.json文件

touch ./traefik/acme.json
chmod 600 .traefik/acme.json

使用以下命令创建容器:

docker run --network=traefik-network -p 80:80 -p 443:443 -v /var/run/docker.sock:/var/run/docker.sock -v $PWD/traefik:/etc/traefik --name=traefik traefik:latest --api --docker
相关问题