Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 09:15 UTC
httpcaddyfile: Skip `automate` when `auto_https off` is specified (#5110)
Francis Lavoie committed
Oct 4, 2022 at 22:58 UTC
2808de1e30b873f9c8f4693eae59bd56f20ebbbe
2 files changed
+68
-4
caddyconfig/httpcaddyfile/tlsapp.go
+10
-4
@@ -48,6 +48,10 @@ func (st ServerType) buildTLSApp(
48
if hsp, ok := options["https_port"].(int); ok {
49
httpsPort = strconv.Itoa(hsp)
50
}
51
+ autoHTTPS := "on"
52
+ if ah, ok := options["auto_https"].(string); ok {
53
+ autoHTTPS = ah
54
+ }
55
56
// count how many server blocks have a TLS-enabled key with
57
// no host, and find all hosts that share a server block with
@@ -331,10 +335,12 @@ func (st ServerType) buildTLSApp(
335
internalAP := &caddytls.AutomationPolicy{
336
IssuersRaw: []json.RawMessage{json.RawMessage(`{"module":"internal"}`)},
337
}
334
- for h := range httpsHostsSharedWithHostlessKey {
335
- al = append(al, h)
336
- if !certmagic.SubjectQualifiesForPublicCert(h) {
337
- internalAP.Subjects = append(internalAP.Subjects, h)
338
+ if autoHTTPS != "off" {
339
+ for h := range httpsHostsSharedWithHostlessKey {
340
+ al = append(al, h)
341
+ if !certmagic.SubjectQualifiesForPublicCert(h) {
342
+ internalAP.Subjects = append(internalAP.Subjects, h)
343
+ }
344
}
345
}
346
if len(al) > 0 {
caddytest/integration/caddyfile_adapt/tls_automation_policies_10.txt
new
+58
@@ -0,0 +1,58 @@
1
+# example from issue #4667
2
+{
3
+ auto_https off
4
+}
5
+
6
+https://, example.com {
7
+ tls test.crt test.key
8
+ respond "Hello World"
9
+}
10
+----------
11
+{
12
+ "apps": {
13
+ "http": {
14
+ "servers": {
15
+ "srv0": {
16
+ "listen": [
17
+ ":443"
18
+ ],
19
+ "routes": [
20
+ {
21
+ "handle": [
22
+ {
23
+ "body": "Hello World",
24
+ "handler": "static_response"
25
+ }
26
+ ]
27
+ }
28
+ ],
29
+ "tls_connection_policies": [
30
+ {
31
+ "certificate_selection": {
32
+ "any_tag": [
33
+ "cert0"
34
+ ]
35
+ }
36
+ }
37
+ ],
38
+ "automatic_https": {
39
+ "disable": true
40
+ }
41
+ }
42
+ }
43
+ },
44
+ "tls": {
45
+ "certificates": {
46
+ "load_files": [
47
+ {
48
+ "certificate": "test.crt",
49
+ "key": "test.key",
50
+ "tags": [
51
+ "cert0"
52
+ ]
53
+ }
54
+ ]
55
+ }
56
+ }
57
+ }
58
+}
\ No newline at end of file