mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-04 02:42:34 +02:00
clarify some error messages
This commit is contained in:
parent
0d625c8399
commit
8aa1c0e7ee
3 changed files with 20 additions and 4 deletions
|
@ -49,7 +49,7 @@ const (
|
||||||
HealthCheckTimeoutDefault = 5 * time.Second
|
HealthCheckTimeoutDefault = 5 * time.Second
|
||||||
|
|
||||||
WakeTimeoutDefault = "30s"
|
WakeTimeoutDefault = "30s"
|
||||||
StopTimeoutDefault = "10s"
|
StopTimeoutDefault = "30s"
|
||||||
StopMethodDefault = "stop"
|
StopMethodDefault = "stop"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -294,6 +294,9 @@ func (w *Watcher) watchUntilDestroy() (returnCause error) {
|
||||||
case errors.Is(err, context.Canceled):
|
case errors.Is(err, context.Canceled):
|
||||||
continue
|
continue
|
||||||
case err != nil:
|
case err != nil:
|
||||||
|
if errors.Is(err, context.DeadlineExceeded) {
|
||||||
|
err = errors.New("timeout waiting for container to stop, please set a higher value for `stop_timeout`")
|
||||||
|
}
|
||||||
w.Err(err).Msgf("container stop with method %q failed", w.StopMethod)
|
w.Err(err).Msgf("container stop with method %q failed", w.StopMethod)
|
||||||
default:
|
default:
|
||||||
w.LogReason("container stopped", "idle timeout")
|
w.LogReason("container stopped", "idle timeout")
|
||||||
|
|
|
@ -12,6 +12,7 @@ package reverseproxy
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -207,13 +208,25 @@ func copyHeader(dst, src http.Header) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ReverseProxy) errorHandler(rw http.ResponseWriter, r *http.Request, err error, writeHeader bool) {
|
func (p *ReverseProxy) errorHandler(rw http.ResponseWriter, r *http.Request, err error, writeHeader bool) {
|
||||||
|
reqURL := r.Host + r.RequestURI
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, context.Canceled),
|
case errors.Is(err, context.Canceled),
|
||||||
errors.Is(err, io.EOF):
|
errors.Is(err, io.EOF),
|
||||||
logger.Debug().Err(err).Str("url", r.URL.String()).Msg("http proxy error")
|
errors.Is(err, context.DeadlineExceeded):
|
||||||
|
logger.Debug().Err(err).Str("url", reqURL).Msg("http proxy error")
|
||||||
default:
|
default:
|
||||||
logger.Err(err).Str("url", r.URL.String()).Msg("http proxy error")
|
var recordErr tls.RecordHeaderError
|
||||||
|
if errors.As(err, &recordErr) {
|
||||||
|
logger.Error().
|
||||||
|
Str("url", reqURL).
|
||||||
|
Msgf(`scheme was likely misconfigured as https,
|
||||||
|
try setting "proxy.%s.scheme" back to "http"`, p.TargetName)
|
||||||
|
logging.Err(err).Msg("underlying error")
|
||||||
|
} else {
|
||||||
|
logger.Err(err).Str("url", reqURL).Msg("http proxy error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if writeHeader {
|
if writeHeader {
|
||||||
rw.WriteHeader(http.StatusInternalServerError)
|
rw.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue