Caddy with .local subdomains

1. The problem I’m having:

I have a Caddy setup I’ve been trying to do for 2 days, basically I have a laptop running headless debian connected to a wifi network. I have a bunch of docker containers running with various web UIs that I can access with the machine-ip:whatever-port…

I’ve learned about mDNS and I wanted to utilize that so I installed avahi-daemon and I can (mostly) find the device with debian.local for now.

So I set up Caddy so I can access the different web UIs using different subdomains, the reverse proxy with no subdomain works (no TLS though) but all the subdomain reverse proxies just don’t resolve whatsoever.

2. Error messages and/or full log output:

Firefox just says: “Hmm. We’re having trouble finding that site.”, here is curl error:

PS C:\Users\Psycho> curl dg.debian.local
curl : The remote name could not be resolved: 'dg.debian.local'
At line:1 char:1
+ curl dg.debian.local
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExcepti
   on
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

3. Caddy version:

v2.8.4

4. How I installed and ran Caddy:

I installed Caddy following EXACTLY this: Install — Caddy Documentation (not docker, just a debian package)

a. System environment:

Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

b. Command:

Tried both

caddy run
caddy start

and currently running the service (non-api)

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name
* {
        tls internal
}

debian.local {
        reverse_proxy 127.0.0.1:5001
}

dg.debian.local {
        reverse_proxy 127.0.0.1:5001
}

jf.debian.local {
        reverse_proxy 127.0.0.1:8096
}

js.debian.local {
        reverse_proxy 127.0.0.1:5055
}

rdr.debian.local {
        reverse_proxy 127.0.0.1:7878
}

snr.debian.local {
        reverse_proxy 127.0.0.1:8989
}

bzr.debian.local {
        reverse_proxy 127.0.0.1:6767
}

plr.debian.local {
        reverse_proxy 127.0.0.1:9696
}

qb.debian.local {
        reverse_proxy 127.0.0.1:8081
}

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
1 Like

Howdy @Omar_Kamal, welcome to the Caddy community.

Sounds to me like your Debian host isn’t responding to mDNS requests for subdomains, only for its own actual hostname, which I assume is debian.local.

Caddy can’t really help with this; it can only really do its job once the client has resolved DNS and actually connects to it. Given that your clients aren’t even trying to connect to Caddy because they can’t resolve e.g. dg.debian.local, there’s nothing Caddy can do.

You’ll need to figure out how to get mDNS responding how you need, or maybe just configure your local DNS server directly.