summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2022-01-18 13:29:07 -0500
committerGitHub <noreply@github.com>2022-01-18 11:29:07 -0700
commit1b7ff5d76c7a3c67b6e0f9b51af78d1b227fdea3 (patch)
tree6e03e066729f05595d37473c711160e0319df886 /caddyconfig/httpcaddyfile
parent93a7a45e7e1ca64dc0103af55ab2a0a4b9c6c84f (diff)
httpcaddyfile: Add `default_bind` global option (#4531)
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r--caddyconfig/httpcaddyfile/addresses.go6
-rw-r--r--caddyconfig/httpcaddyfile/options.go1
2 files changed, 6 insertions, 1 deletions
diff --git a/caddyconfig/httpcaddyfile/addresses.go b/caddyconfig/httpcaddyfile/addresses.go
index e2e7771..b33c0f0 100644
--- a/caddyconfig/httpcaddyfile/addresses.go
+++ b/caddyconfig/httpcaddyfile/addresses.go
@@ -213,7 +213,11 @@ func (st *ServerType) listenerAddrsForServerBlockKey(sblock serverBlock, key str
lnHosts = append(lnHosts, cfgVal.Value.([]string)...)
}
if len(lnHosts) == 0 {
- lnHosts = []string{""}
+ if defaultBind, ok := options["default_bind"].(string); ok {
+ lnHosts = []string{defaultBind}
+ } else {
+ lnHosts = []string{""}
+ }
}
// use a map to prevent duplication
diff --git a/caddyconfig/httpcaddyfile/options.go b/caddyconfig/httpcaddyfile/options.go
index 91709cc..016d0df 100644
--- a/caddyconfig/httpcaddyfile/options.go
+++ b/caddyconfig/httpcaddyfile/options.go
@@ -29,6 +29,7 @@ func init() {
RegisterGlobalOption("debug", parseOptTrue)
RegisterGlobalOption("http_port", parseOptHTTPPort)
RegisterGlobalOption("https_port", parseOptHTTPSPort)
+ RegisterGlobalOption("default_bind", parseOptSingleString)
RegisterGlobalOption("grace_period", parseOptDuration)
RegisterGlobalOption("default_sni", parseOptSingleString)
RegisterGlobalOption("order", parseOptOrder)