Skip to content

Commit cf3816c

Browse files
committed
fix: fallback to http if no certificate present
1 parent 8791180 commit cf3816c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/edged/caddy/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,16 @@ func Update(database *gorm.DB, caddyFilePath, nodeId, certDir string) error {
101101

102102
caddyFile := caddyPrefix
103103
for domain, ips := range config {
104+
var tlsDirective string
105+
104106
// Check if we have a TLS certificate for this domain
105-
tlsDirective := "internal"
106107
if _, err := os.Stat(path.Join(certDir, domain+".cert")); err == nil {
107-
tlsDirective = path.Join(certDir, domain+".cert") + " " + path.Join(certDir, domain+".key")
108+
tlsDirective = "tls " + path.Join(certDir, domain+".cert") + " " + path.Join(certDir, domain+".key")
109+
caddyFile += "http://"
108110
}
109111

110112
caddyFile += domain + ` {
111-
tls ` + tlsDirective + `
113+
` + tlsDirective + `
112114
reverse_proxy /.well-known/acme-challenge/* {
113115
to http://172.16.90.1:8081
114116
}

0 commit comments

Comments
 (0)