Skip to content

Commit 6d549a1

Browse files
committed
Default app lookup to default domain
1 parent d0e300a commit 6d549a1

File tree

5 files changed

+7
-28
lines changed

5 files changed

+7
-28
lines changed

internal/server/app_apis.go

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -544,29 +544,16 @@ func (s *Server) MatchApp(hostHeader, matchPath string) (types.AppInfo, error) {
544544
hostHeader = "localhost"
545545
}
546546

547-
// Check if host header matches a known domain
548-
checkDomain := false
549-
if hostHeader != "" && domainMap[hostHeader] {
550-
checkDomain = true
547+
if !domainMap[hostHeader] {
548+
// Request to unknown domain, match against default domain
549+
hostHeader = s.config.System.DefaultDomain
551550
}
552551

553552
for _, appInfo := range apps {
554-
if s.config.System.DisableUnknownDomains {
555-
appDomain := cmp.Or(appInfo.Domain, s.config.System.DefaultDomain)
556-
if hostHeader != appDomain {
557-
// Host header does not match
558-
continue
559-
}
560-
} else {
561-
if checkDomain && appInfo.Domain != hostHeader {
562-
// Request uses known domain, but app is not for this domain
563-
continue
564-
}
565-
566-
if !checkDomain && appInfo.Domain != "" {
567-
// Request does not use known domain, but app is for a domain
568-
continue
569-
}
553+
appDomain := cmp.Or(appInfo.Domain, s.config.System.DefaultDomain)
554+
if hostHeader != appDomain {
555+
// Host header does not match
556+
continue
570557
}
571558

572559
if strings.HasPrefix(matchPath, appInfo.Path) {

internal/server/server.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,6 @@ func (s *Server) setupHTTPSServer() (*http.Server, error) {
469469
magicConfig := certmagic.NewDefault()
470470
magicConfig.OnDemand = &certmagic.OnDemandConfig{
471471
DecisionFunc: func(ctx context.Context, name string) error {
472-
if !s.config.System.DisableUnknownDomains {
473-
// Allow on-demand certificates for unknown domains
474-
return nil
475-
}
476-
477472
if name == s.config.System.DefaultDomain || name == "localhost" || name == "127.0.0.1" {
478473
return nil
479474
}

internal/system/clace.default.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ file_watcher_debounce_millis = 300
5858
node_path = "" # node module lookup paths https://esbuild.github.io/api/#node-paths
5959
container_command = "auto" # "auto" or "docker" or "podman"
6060
default_domain = "localhost" # default domain for apps
61-
disable_unknown_domains = true # disable unknown domains, if default domain is set. Otherwise, unknown domains are allowed
6261
root_serve_list_apps = "auto" # "auto" means serve list_apps app for default domain, "disable" means don't server for any domain,
6362
# any other value means server for specified domain
6463

internal/system/config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func TestServerConfig(t *testing.T) {
4747
testutil.AssertEqualsInt(t, "file debounce", 300, c.System.FileWatcherDebounceMillis)
4848
testutil.AssertEqualsString(t, "node path", "", c.System.NodePath)
4949
testutil.AssertEqualsString(t, "default domain", "localhost", c.System.DefaultDomain)
50-
testutil.AssertEqualsBool(t, "unknown domains", true, c.System.DisableUnknownDomains)
5150

5251
// Global Settings
5352
testutil.AssertEqualsString(t, "server uri", "$CL_HOME/run/clace.sock", c.ServerUri)

internal/types/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ type SystemConfig struct {
206206
NodePath string `toml:"node_path"`
207207
ContainerCommand string `toml:"container_command"`
208208
DefaultDomain string `toml:"default_domain"`
209-
DisableUnknownDomains bool `toml:"disable_unknown_domains"`
210209
RootServeListApps string `toml:"root_serve_list_apps"`
211210

212211
HttpEventRetentionDays int `toml:"http_event_retention_days"`

0 commit comments

Comments
 (0)