diff options
author | Francis Lavoie <[email protected]> | 2020-05-19 18:59:51 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-19 16:59:51 -0600 |
commit | fae064262d9c40393d634660b94d36ce6703aa1c (patch) | |
tree | e450612a8241255d7646a23ef9d1bd88c4a6fabd /caddyconfig/httpcaddyfile/options.go | |
parent | 9ee01dceac0a3e9f71c3b37dfbe3ae04e2f54986 (diff) | |
download | caddy-fae064262d9c40393d634660b94d36ce6703aa1c.tar.gz caddy-fae064262d9c40393d634660b94d36ce6703aa1c.zip |
httpcaddyfile: Add `auto_https` global option (#3284)
Diffstat (limited to 'caddyconfig/httpcaddyfile/options.go')
-rw-r--r-- | caddyconfig/httpcaddyfile/options.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/caddyconfig/httpcaddyfile/options.go b/caddyconfig/httpcaddyfile/options.go index 49a11f6ee..cecb3d4b5 100644 --- a/caddyconfig/httpcaddyfile/options.go +++ b/caddyconfig/httpcaddyfile/options.go @@ -38,6 +38,7 @@ func init() { RegisterGlobalOption("on_demand_tls", parseOptOnDemand) RegisterGlobalOption("local_certs", parseOptTrue) RegisterGlobalOption("key_type", parseOptSingleString) + RegisterGlobalOption("auto_https", parseOptAutoHTTPS) } func parseOptTrue(d *caddyfile.Dispenser) (interface{}, error) { @@ -264,3 +265,18 @@ func parseOptOnDemand(d *caddyfile.Dispenser) (interface{}, error) { } return ond, nil } + +func parseOptAutoHTTPS(d *caddyfile.Dispenser) (interface{}, error) { + d.Next() // consume parameter name + if !d.Next() { + return "", d.ArgErr() + } + val := d.Val() + if d.Next() { + return "", d.ArgErr() + } + if val != "off" && val != "disable_redirects" { + return "", d.Errf("auto_https must be either 'off' or 'disable_redirects'") + } + return val, nil +} |