Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 16:00 UTC
httpcaddyfile: Override global `dns` with `acme_dns` (fix #7294) (#7458)
This brings the behaviour in line with what the documentation implies.
Aditya Bhargava committed
Feb 15, 2026 at 04:04 UTC
d6a6b486db238b7fd2be850331687267aa6bc83a
2 files changed
+85
-3
caddyconfig/httpcaddyfile/tlsapp.go
+2
-3
@@ -548,9 +548,8 @@ func fillInGlobalACMEDefaults(issuer certmagic.Issuer, options map[string]any) e
548
if acmeIssuer.Challenges.DNS == nil {
549
acmeIssuer.Challenges.DNS = new(caddytls.DNSChallengeConfig)
550
}
551
- // If global `dns` is set, do NOT set provider in issuer, just set empty dns config
552
- if globalDNS == nil && acmeIssuer.Challenges.DNS.ProviderRaw == nil {
553
- // Set a global DNS provider if `acme_dns` is set and `dns` is NOT set
551
+ if globalACMEDNS != nil && acmeIssuer.Challenges.DNS.ProviderRaw == nil {
552
+ // Set a global DNS provider if `acme_dns` is set
553
acmeIssuer.Challenges.DNS.ProviderRaw = caddyconfig.JSONModuleObject(globalACMEDNS, "name", globalACMEDNS.(caddy.Module).CaddyModule().ID.Name(), nil)
554
}
555
}
caddytest/integration/caddyfile_adapt/tls_acme_dns_override_global_dns.caddyfiletest
new
+83
@@ -0,0 +1,83 @@
1
+{
2
+ dns mock foo
3
+ acme_dns mock bar
4
+}
5
+
6
+localhost {
7
+ tls {
8
+ resolvers 8.8.8.8 8.8.4.4
9
+ }
10
+}
11
+----------
12
+{
13
+ "apps": {
14
+ "http": {
15
+ "servers": {
16
+ "srv0": {
17
+ "listen": [
18
+ ":443"
19
+ ],
20
+ "routes": [
21
+ {
22
+ "match": [
23
+ {
24
+ "host": [
25
+ "localhost"
26
+ ]
27
+ }
28
+ ],
29
+ "terminal": true
30
+ }
31
+ ]
32
+ }
33
+ }
34
+ },
35
+ "tls": {
36
+ "automation": {
37
+ "policies": [
38
+ {
39
+ "subjects": [
40
+ "localhost"
41
+ ],
42
+ "issuers": [
43
+ {
44
+ "challenges": {
45
+ "dns": {
46
+ "provider": {
47
+ "argument": "bar",
48
+ "name": "mock"
49
+ },
50
+ "resolvers": [
51
+ "8.8.8.8",
52
+ "8.8.4.4"
53
+ ]
54
+ }
55
+ },
56
+ "module": "acme"
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "issuers": [
62
+ {
63
+ "challenges": {
64
+ "dns": {
65
+ "provider": {
66
+ "argument": "bar",
67
+ "name": "mock"
68
+ }
69
+ }
70
+ },
71
+ "module": "acme"
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ },
77
+ "dns": {
78
+ "argument": "foo",
79
+ "name": "mock"
80
+ }
81
+ }
82
+ }
83
+}