How does Caddy DNS work? How is resolving? Is this Chrome-specific magic?

I just started using Caddy, and couldn’t find this elsewhere. I started with this:

*.bar.localhost {
	reverse_proxy localhost:1337

And to my amazement, resolves in Chrome, correctly proxied to http://localhost:1337! Firefox also resolves (though doesn’t accept the cert - a separate issue).

However, curl reports “Cannot resolve host” (as expected).

But how does resolve to anything in Chrome/Firefox? Does Caddy install its own DNS server somehow? Does it have some magic browser integration?

1 Like

I think modern browsers now resolve anything .localhost to or ::1. Some OSes do this as well now with their system resolvers.

From a quick search, Firefox added support for this in this commit Bug 1220810 - Hardcode localhost to loopback, r=ckerschb,necko-review… · mozilla/gecko-dev@70d15af · GitHub

See here:


There’s an IETF draft about this topic:

1 Like

@francislavoie aha, thank you! So yeah, it turns out resolves to in Chrome and Firefox, and has done for quite a while - I just discovered this feature after installing Caddy, which is why I thought it was some dark magic in Caddy.

This browser override of standard DNS disturbs me a bit, but I must admit it’s convenient …

1 Like