Refetch dns when using reverse_proxy

1. Caddy version (caddy version):


2. How I run Caddy:

Running in Docker, in Kubernetes.

a. System environment:

See Above

b. Command:

caddy run

c. Service/unit/compose file:

FROM caddy:2.4.1

COPY Caddyfile /etc/caddy/Caddyfile

EXPOSE 80 443

d. My complete Caddyfile or JSON config:

  auto_https off

:80, :443 {
  reverse_proxy /http-bind http://ejabberd:5281 {
    transport http {
      dial_timeout 3s

  log {
    output stdout
    format console

3. The problem I’m having:

When running Caddy as a reverse proxy in my kubernetes cluster, when pods restart they come back up with a new internal ip address. The first request that gets reverse proxied to them then fails. Subsequent requests succeed just fine.

What I would like to happen is have some way to tell caddy to refetch DNS for these reverse proxy directives if they end up hanging for a certain amount of time.

4. Error messages and/or full log output:


5. What I already tried:

Tries using the settings in reverse_proxy like the health checks, but I’m not sure if thats the right solution.

6. Links to relevant resources:


I think the lb_try_duration option might be what you want here. Give it a value like 2s or something and it’ll retry the request for up to two seconds with the interval of lb_try_interval (default 250ms which should be fine).

This topic was automatically closed after 30 days. New replies are no longer allowed.