使用下面的配置,颁发的证书适用于www.example.org
和abc.example.org
,但不适用于www.abc.example.org
。
http:
routers:
web-router:
rule: "Host(`example.org`) ||
Host(`www.example.org`) ||
HostRegexp(`{subdomain:[a-z-]+}.example.org`) ||
HostRegexp(`www.{subdomain:[a-z-]+}.example.org`)"
entryPoints:
- web
middlewares:
- redirect
- csrf
service: django
web-secure-router:
rule: "Host(`example.org`) ||
Host(`www.example.org`) ||
HostRegexp(`{subdomain:[a-z-]+}.example.org`) ||
HostRegexp(`www.{subdomain:[a-z-]+}.example.org`)"
entryPoints:
- web-secure
middlewares:
- csrf
service: django
tls:
certResolver: letsencrypt
domains:
- main: "*.example.org"
sans:
- "example.org"
certificatesResolvers:
letsencrypt:
acme:
email: "email@example.com"
storage: /etc/traefik/acme/acme.json
dnsChallenge:
provider: route53
delayBeforeCheck: 0
在DNS我有example.org
和*.example.org
的A
记录。
是否有可能同时获得适用于www.*.example.org
和*.example.org
的证书?
LetsEncrypt不嵌套通配符。您可以获得*.example.org
或*.sub.example.org
的证书,但*.example.org
在*
的定义中不包括.
。
此外,DNS本身不支持嵌套或嵌入通配符。
如果您创建www.*.example.com
的记录,然后查询www.foo.example.com
之类的内容,您可以看到这一点。您将得到一个NXDOMAIN响应。如果您查询www.*.example.com
(或将FQDN包装在单引号中以避免shell展开),那么您将获得您创建的A记录。当星号不在记录的开头时,该星号变为文字字符。
➤ host www.sub.productionwebsite.com 8.8.8.8
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:
Host www.sub.productionwebsite.com not found: 3(NXDOMAIN)
~
➤ host 'www.*.productionwebsite.com' 8.8.8.8
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:
www.*.productionwebsite.com has address 10.68.0.73