@marcel91200 / caddy Mirror · read-only / commits / 5bd96a6a
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 13, 21:45 UTC

httpcaddyfile: Support explicitly turning off `strict_sni_host` (#4592)

Francis Lavoie committed Mar 1, 2022 at 20:02 UTC 5bd96a6ac22849cd9fbbaae5285f0161e272b8e4
2 files changed +17 -6
caddyconfig/httpcaddyfile/serveroptions.go
+7 -4
@@ -157,11 +157,14 @@ func unmarshalCaddyfileServerOptions(d *caddyfile.Dispenser) (interface{}, error
157 serverOpts.ExperimentalHTTP3 = true
158
159 case "strict_sni_host":
160 - if d.NextArg() {
161 - return nil, d.ArgErr()
160 + if d.NextArg() && d.Val() != "insecure_off" && d.Val() != "on" {
161 + return nil, d.Errf("strict_sni_host only supports 'on' or 'insecure_off', got '%s'", d.Val())
162 + }
163 + boolVal := true
164 + if d.Val() == "insecure_off" {
165 + boolVal = false
166 }
163 - trueBool := true
164 - serverOpts.StrictSNIHost = &trueBool
167 + serverOpts.StrictSNIHost = &boolVal
168
169 default:
170 return nil, d.Errf("unrecognized protocol option '%s'", d.Val())
caddytest/integration/caddyfile_adapt/global_server_options_multi.txt
+10 -2
@@ -3,6 +3,9 @@
3 timeouts {
4 idle 90s
5 }
6 + protocol {
7 + strict_sni_host insecure_off
8 + }
9 }
10 servers :80 {
11 timeouts {
@@ -13,6 +16,9 @@
16 timeouts {
17 idle 30s
18 }
19 + protocol {
20 + strict_sni_host
21 + }
22 }
23 }
24
@@ -46,7 +52,8 @@ http://bar.com {
52 ],
53 "terminal": true
54 }
49 - ]
55 + ],
56 + "strict_sni_host": true
57 },
58 "srv1": {
59 "listen": [
@@ -70,7 +77,8 @@ http://bar.com {
77 "listen": [
78 ":8080"
79 ],
73 - "idle_timeout": 90000000000
80 + "idle_timeout": 90000000000,
81 + "strict_sni_host": false
82 }
83 }
84 }