Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
httpcaddyfile: Decrement counter when removing conn policy (fix #3906)
Matthew Holt committed
Dec 7, 2020 at 14:22 UTC
7e719157d9b7002fc09de63344f7b4fdfa7e9f57
2 files changed
+139
caddyconfig/httpcaddyfile/tlsapp.go
+2
@@ -487,6 +487,7 @@ func consolidateAutomationPolicies(aps []*caddytls.AutomationPolicy) []*caddytls
487
488
// remove or combine duplicate policies
489
for i := 0; i < len(aps); i++ {
490
+ // compare only with next policies; we sorted by specificity so we must not delete earlier policies
491
for j := i + 1; j < len(aps); j++ {
492
// if they're exactly equal in every way, just keep one of them
493
if reflect.DeepEqual(aps[i], aps[j]) {
@@ -526,6 +527,7 @@ func consolidateAutomationPolicies(aps []*caddytls.AutomationPolicy) []*caddytls
527
}
528
}
529
aps = append(aps[:j], aps[j+1:]...)
530
+ j--
531
}
532
}
533
}
caddytest/integration/caddyfile_adapt/tls_conn_policy_consolidate.txt
new
+137
@@ -0,0 +1,137 @@
1
+# https://github.com/caddyserver/caddy/issues/3906
2
+a.a {
3
+ tls internal
4
+ respond 403
5
+}
6
+
7
+http://b.b https://b.b:8443 {
8
+ tls internal
9
+ respond 404
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
+ "a.a"
26
+ ]
27
+ }
28
+ ],
29
+ "handle": [
30
+ {
31
+ "handler": "subroute",
32
+ "routes": [
33
+ {
34
+ "handle": [
35
+ {
36
+ "handler": "static_response",
37
+ "status_code": 403
38
+ }
39
+ ]
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "terminal": true
45
+ }
46
+ ]
47
+ },
48
+ "srv1": {
49
+ "listen": [
50
+ ":80"
51
+ ],
52
+ "routes": [
53
+ {
54
+ "match": [
55
+ {
56
+ "host": [
57
+ "b.b"
58
+ ]
59
+ }
60
+ ],
61
+ "handle": [
62
+ {
63
+ "handler": "subroute",
64
+ "routes": [
65
+ {
66
+ "handle": [
67
+ {
68
+ "handler": "static_response",
69
+ "status_code": 404
70
+ }
71
+ ]
72
+ }
73
+ ]
74
+ }
75
+ ],
76
+ "terminal": true
77
+ }
78
+ ],
79
+ "automatic_https": {
80
+ "skip": [
81
+ "b.b"
82
+ ]
83
+ }
84
+ },
85
+ "srv2": {
86
+ "listen": [
87
+ ":8443"
88
+ ],
89
+ "routes": [
90
+ {
91
+ "match": [
92
+ {
93
+ "host": [
94
+ "b.b"
95
+ ]
96
+ }
97
+ ],
98
+ "handle": [
99
+ {
100
+ "handler": "subroute",
101
+ "routes": [
102
+ {
103
+ "handle": [
104
+ {
105
+ "handler": "static_response",
106
+ "status_code": 404
107
+ }
108
+ ]
109
+ }
110
+ ]
111
+ }
112
+ ],
113
+ "terminal": true
114
+ }
115
+ ]
116
+ }
117
+ }
118
+ },
119
+ "tls": {
120
+ "automation": {
121
+ "policies": [
122
+ {
123
+ "subjects": [
124
+ "a.a",
125
+ "b.b"
126
+ ],
127
+ "issuers": [
128
+ {
129
+ "module": "internal"
130
+ }
131
+ ]
132
+ }
133
+ ]
134
+ }
135
+ }
136
+ }
137
+}
\ No newline at end of file