Browse Source

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

master
Francis Lavoie 3 years ago
committed by GitHub
parent
commit
5bd96a6ac2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      caddyconfig/httpcaddyfile/serveroptions.go
  2. 12
      caddytest/integration/caddyfile_adapt/global_server_options_multi.txt

11
caddyconfig/httpcaddyfile/serveroptions.go

@ -157,11 +157,14 @@ func unmarshalCaddyfileServerOptions(d *caddyfile.Dispenser) (interface{}, error
serverOpts.ExperimentalHTTP3 = true serverOpts.ExperimentalHTTP3 = true
case "strict_sni_host": case "strict_sni_host":
if d.NextArg() { if d.NextArg() && d.Val() != "insecure_off" && d.Val() != "on" {
return nil, d.ArgErr() return nil, d.Errf("strict_sni_host only supports 'on' or 'insecure_off', got '%s'", d.Val())
}
boolVal := true
if d.Val() == "insecure_off" {
boolVal = false
} }
trueBool := true serverOpts.StrictSNIHost = &boolVal
serverOpts.StrictSNIHost = &trueBool
default: default:
return nil, d.Errf("unrecognized protocol option '%s'", d.Val()) return nil, d.Errf("unrecognized protocol option '%s'", d.Val())

12
caddytest/integration/caddyfile_adapt/global_server_options_multi.txt

@ -3,6 +3,9 @@
timeouts { timeouts {
idle 90s idle 90s
} }
protocol {
strict_sni_host insecure_off
}
} }
servers :80 { servers :80 {
timeouts { timeouts {
@ -13,6 +16,9 @@
timeouts { timeouts {
idle 30s idle 30s
} }
protocol {
strict_sni_host
}
} }
} }
@ -46,7 +52,8 @@ http://bar.com {
], ],
"terminal": true "terminal": true
} }
] ],
"strict_sni_host": true
}, },
"srv1": { "srv1": {
"listen": [ "listen": [
@ -70,7 +77,8 @@ http://bar.com {
"listen": [ "listen": [
":8080" ":8080"
], ],
"idle_timeout": 90000000000 "idle_timeout": 90000000000,
"strict_sni_host": false
} }
} }
} }

Loading…
Cancel
Save