How to ipv6 together with Nginx?

I try to run latest Caddy under debian linux.

I have one ipv4 and some ipv6. Nginx is running on ports 80 and 443 on the ipv4.
How do I configure Caddy to listen to ports 80 and 443 only on one specific ipv6?

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

Because I first want to test Caddy before I (perhaps) migrate from Nginx.

I updated to 2.5.0 and the bind now works. thanks!

3 Likes