summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorMark Sargent <99003+sarge@users.noreply.github.com>2020-02-27 12:01:47 +1300
committerGitHub <noreply@github.com>2020-02-26 16:01:47 -0700
commit2de0acc11fcaaed9e4b3561d9a2d1457f015e9e3 (patch)
tree3b6cea17a201102cc2a4efec2bcba338fc16066e /modules/caddyhttp
parent5d97522d18da39cd3f9dd309774a5ad2c51f4c51 (diff)
Initial implementation of global default SNI option (#3047)
* add global default sni * fixed grammar * httpcaddyfile: Reduce some duplicated code * Um, re-commit already-committed commit, I guess? (sigh) Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/caddyhttp.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go
index 135afef..f78b198 100644
--- a/modules/caddyhttp/caddyhttp.go
+++ b/modules/caddyhttp/caddyhttp.go
@@ -29,6 +29,7 @@ import (
"github.com/caddyserver/caddy/v2"
"github.com/lucas-clemente/quic-go/http3"
+ "github.com/mholt/certmagic"
"go.uber.org/zap"
)
@@ -111,6 +112,10 @@ type App struct {
// affect functionality.
Servers map[string]*Server `json:"servers,omitempty"`
+ // DefaultSNI if set configures all certificate lookups to fallback to use
+ // this SNI name if a more specific certificate could not be found
+ DefaultSNI string `json:"default_sni,omitempty"`
+
servers []*http.Server
h3servers []*http3.Server
h3listeners []net.PacketConn
@@ -134,6 +139,8 @@ func (app *App) Provision(ctx caddy.Context) error {
repl := caddy.NewReplacer()
+ certmagic.Default.DefaultServerName = app.DefaultSNI
+
// this provisions the matchers for each route,
// and prepares auto HTTP->HTTP redirects, and
// is required before we provision each server