summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorGregory Dosh <6432753+GregoryDosh@users.noreply.github.com>2020-05-11 15:17:59 -0500
committerGitHub <noreply@github.com>2020-05-11 14:17:59 -0600
commitd5341625561bf67c40241a4fb649b0a4991e71b2 (patch)
treefa6c25ff03a9419777aa5ef230b90db8dbf55c01 /modules/caddyhttp
parent5bde8d705b9c9cae6751ccf95b7b8acfc1bbb7f5 (diff)
caddyhttp: Match hostnames with wildcards to loggers (#3378)
* adding wildcard matching of logger names * reordering precedence for more specific loggers to match first * removing dependence on certmagic and extra loop Co-authored-by: GregoryDosh <GregoryDosh@users.noreply.github.com>
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/server.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go
index 55da253..38555e7 100644
--- a/modules/caddyhttp/server.go
+++ b/modules/caddyhttp/server.go
@@ -456,6 +456,20 @@ func (slc ServerLogConfig) getLoggerName(host string) string {
if loggerName, ok := slc.LoggerNames[host]; ok {
return loggerName
}
+
+ // Try matching wildcard domains if other non-specific loggers exist
+ labels := strings.Split(host, ".")
+ for i := range labels {
+ if labels[i] == "" {
+ continue
+ }
+ labels[i] = "*"
+ wildcardHost := strings.Join(labels, ".")
+ if loggerName, ok := slc.LoggerNames[wildcardHost]; ok {
+ return loggerName
+ }
+ }
+
return slc.DefaultLoggerName
}