@marcel91200 / caddy Mirror · read-only / commits / 012d2353
Fork 0

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, 01:30 UTC

httpcaddyfile: Empty tls policy for internal http localhost (#4398)

* test: replicated empty tls automation policy issue * fix: empty tls policy for an http:// endpoint running on a non-standard http port

Marc Easen committed Oct 26, 2021 at 20:54 UTC 012d235314fcc2a27302d00ee6f53459e54c0eb8
2 files changed +99 -1
caddyconfig/httpcaddyfile/directives.go
+1 -1
@@ -485,7 +485,7 @@ func (sb serverBlock) hostsFromKeysNotHTTP(httpPort string) []string {
485 if addr.Host == "" {
486 continue
487 }
488 - if addr.Scheme != "http" && addr.Port != httpPort {
488 + if addr.Scheme != "http" || addr.Port != httpPort {
489 hostMap[addr.Host] = struct{}{}
490 }
491 }
caddytest/integration/caddyfile_adapt/tls_automation_policies_8.txt new
+98
@@ -0,0 +1,98 @@
1 +# (this Caddyfile is contrived, but based on issues #4176 and #4198)
2 +
3 +http://example.com {
4 +}
5 +
6 +https://example.com {
7 + tls abc@example.com
8 +}
9 +
10 +http://localhost:8081 {
11 +}
12 +
13 +----------
14 +{
15 + "apps": {
16 + "http": {
17 + "servers": {
18 + "srv0": {
19 + "listen": [
20 + ":443"
21 + ],
22 + "routes": [
23 + {
24 + "match": [
25 + {
26 + "host": [
27 + "example.com"
28 + ]
29 + }
30 + ],
31 + "terminal": true
32 + }
33 + ]
34 + },
35 + "srv1": {
36 + "listen": [
37 + ":80"
38 + ],
39 + "routes": [
40 + {
41 + "match": [
42 + {
43 + "host": [
44 + "example.com"
45 + ]
46 + }
47 + ],
48 + "terminal": true
49 + }
50 + ]
51 + },
52 + "srv2": {
53 + "listen": [
54 + ":8081"
55 + ],
56 + "routes": [
57 + {
58 + "match": [
59 + {
60 + "host": [
61 + "localhost"
62 + ]
63 + }
64 + ],
65 + "terminal": true
66 + }
67 + ],
68 + "automatic_https": {
69 + "skip": [
70 + "localhost"
71 + ]
72 + }
73 + }
74 + }
75 + },
76 + "tls": {
77 + "automation": {
78 + "policies": [
79 + {
80 + "subjects": [
81 + "example.com"
82 + ],
83 + "issuers": [
84 + {
85 + "email": "abc@example.com",
86 + "module": "acme"
87 + },
88 + {
89 + "email": "abc@example.com",
90 + "module": "zerossl"
91 + }
92 + ]
93 + }
94 + ]
95 + }
96 + }
97 + }
98 +}
\ No newline at end of file