httpcaddyfile: Support explicitly turning off strict_sni_host (#4592)

This commit is contained in:
Francis Lavoie 2022-03-01 20:02:39 -05:00 committed by GitHub
parent ac14b64e08
commit 5bd96a6ac2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

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

View File

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