How to ipv6 together with Nginx?

Hi :wave:

With the release of caddy v2.5.0 (less than 1 hour ago) you can specify default_bind tcp6/[::] as global option in your Caddyfile.

See Global options (Caddyfile) — Caddy Documentation and Conventions — Caddy Documentation

And maybe the underlying net package - net - pkg.go.dev, because tcp4/0.0.0.0 and tcp6/[::] are not mentioned in the docs (yet).

{
    default_bind tcp6/[::]
}

localhost {
    respond "localhost"
}


*.localhost {
    respond "_wildcard.localhost"
}

Alternatively, you would need to add bind tcp6/[::] to each of your vhosts:

localhost {
    bind tcp6/[::]
    respond "localhost"
}


*.localhost {
    bind tcp6/[::]
    respond "_wildcard.localhost"
}

bind (Caddyfile directive) — Caddy Documentation will work just fine if you are below v2.5.0.

2 Likes