aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/reverseproxy
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2023-10-11 11:50:44 -0400
committerGitHub <[email protected]>2023-10-11 09:50:44 -0600
commita8586b05aac81435f2a3d929a762fc994accbfdd (patch)
treecfdf83bf6650f9fdb52a6131828f4e5ecf49a773 /modules/caddyhttp/reverseproxy
parent05dbe1c171846b0b683dedbe2c4c20683e867ba0 (diff)
downloadcaddy-a8586b05aac81435f2a3d929a762fc994accbfdd.tar.gz
caddy-a8586b05aac81435f2a3d929a762fc994accbfdd.zip
reverseproxy: Add logging for dynamic A upstreams (#5857)
Diffstat (limited to 'modules/caddyhttp/reverseproxy')
-rw-r--r--modules/caddyhttp/reverseproxy/upstreams.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/upstreams.go b/modules/caddyhttp/reverseproxy/upstreams.go
index 528e2c5ef..2d21a5ca4 100644
--- a/modules/caddyhttp/reverseproxy/upstreams.go
+++ b/modules/caddyhttp/reverseproxy/upstreams.go
@@ -251,6 +251,8 @@ type AUpstreams struct {
Versions *IPVersions `json:"versions,omitempty"`
resolver *net.Resolver
+
+ logger *zap.Logger
}
// CaddyModule returns the Caddy module information.
@@ -261,7 +263,8 @@ func (AUpstreams) CaddyModule() caddy.ModuleInfo {
}
}
-func (au *AUpstreams) Provision(_ caddy.Context) error {
+func (au *AUpstreams) Provision(ctx caddy.Context) error {
+ au.logger = ctx.Logger()
if au.Refresh == 0 {
au.Refresh = caddy.Duration(time.Minute)
}
@@ -343,6 +346,11 @@ func (au AUpstreams) GetUpstreams(r *http.Request) ([]*Upstream, error) {
name := repl.ReplaceAll(au.Name, "")
port := repl.ReplaceAll(au.Port, "")
+ au.logger.Debug("refreshing A upstreams",
+ zap.String("version", ipVersion),
+ zap.String("name", name),
+ zap.String("port", port))
+
ips, err := au.resolver.LookupIP(r.Context(), ipVersion, name)
if err != nil {
return nil, err
@@ -350,6 +358,8 @@ func (au AUpstreams) GetUpstreams(r *http.Request) ([]*Upstream, error) {
upstreams := make([]Upstream, len(ips))
for i, ip := range ips {
+ au.logger.Debug("discovered A record",
+ zap.String("ip", ip.String()))
upstreams[i] = Upstream{
Dial: net.JoinHostPort(ip.String(), port),
}