Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 07:00 UTC
cmd: Better error handling when reloading (#6601)
* caddyhttp: Limit auto-HTTPS error logs to 100 domains * Improve error message and increase error size limit
Matt Holt committed
Oct 1, 2024 at 20:31 UTC
c8adb1b553412253d5f166065635ab809d3eef33
3 files changed
+6
-2
cmd/commandfuncs.go
+1
-1
@@ -716,7 +716,7 @@ func AdminAPIRequest(adminAddr, method, uri string, headers http.Header, body io
716
717
// if it didn't work, let the user know
718
if resp.StatusCode >= 400 {
719
- respBody, err := io.ReadAll(io.LimitReader(resp.Body, 1024*10))
719
+ respBody, err := io.ReadAll(io.LimitReader(resp.Body, 1024*1024*2))
720
if err != nil {
721
return nil, fmt.Errorf("HTTP %d: reading error message: %v", resp.StatusCode, err)
722
}
modules/caddyhttp/autohttps.go
+1
-1
@@ -732,7 +732,7 @@ func (app *App) automaticHTTPSPhase2() error {
732
)
733
err := app.tlsApp.Manage(app.allCertDomains)
734
if err != nil {
735
- return fmt.Errorf("managing certificates for %v: %s", app.allCertDomains, err)
735
+ return fmt.Errorf("managing certificates for %d domains: %s", len(app.allCertDomains), err)
736
}
737
app.allCertDomains = nil // no longer needed; allow GC to deallocate
738
return nil
modules/caddytls/tls.go
+4
@@ -447,6 +447,10 @@ func (t *TLS) Manage(names []string) error {
447
for ap, names := range policyToNames {
448
err := ap.magic.ManageAsync(t.ctx.Context, names)
449
if err != nil {
450
+ const maxNamesToDisplay = 100
451
+ if len(names) > maxNamesToDisplay {
452
+ names = append(names[:maxNamesToDisplay], fmt.Sprintf("(%d more...)", len(names)-maxNamesToDisplay))
453
+ }
454
return fmt.Errorf("automate: manage %v: %v", names, err)
455
}
456
for _, name := range names {