To set up split-horizon DNS, make your local resolver return the reverse proxy’s private IP for the app’s hostname. Have VPN clients send queries for that domain to the same resolver and give them a route to the proxy. For a private-only app, leave the name out of public DNS. Tailscale split DNS guide · Tailscale subnet router guide
Choose the DNS answers
This IPv4 example starts with Pi-hole at 192.168.50.53, Caddy at 192.168.50.10, and an HTTP app listening at 127.0.0.1:8080 on the Caddy host. It uses an existing tailnet with a Linux device on the LAN and assumes Caddy runs under its official systemd service. Substitute your own addresses, app port, and domain throughout.
| Client | Resolver for app.lab.example.com | Expected answer |
|---|---|---|
| Home LAN | Pi-hole at 192.168.50.53 | 192.168.50.10 |
| Away with Tailscale connected | Pi-hole via a restricted nameserver for lab.example.com | 192.168.50.10 |
| Away with VPN disconnected | Public DNS | No public address for this private app. If the hostname has a public address record, expect its public DNS answer. |
The local record sends browsers to Caddy. The proxy then forwards the request to the app’s configured upstream. Tailscale split DNS guide · Caddy reverse_proxy examples
Add the local record in Pi-hole
On the Pi-hole host, add the app hostname and the proxy’s LAN address to the dns.hosts list. Use the command below to set the entire list if dns.hosts is editable in the CLI. If FTLCONF_dns_hosts is set, dns.hosts is read-only in the CLI. If you already have local records, keep those entries in the array and add the new one. Pi-hole dns.hosts configuration
sudo pihole-FTL --config dns.hosts '["192.168.50.10 app.lab.example.com"]'
Set your router’s LAN DHCP settings to give clients 192.168.50.53 as their DNS server. For a trial on one device, set that device’s DNS server to 192.168.50.53 manually. Pi-hole post-install configuration
Configure Caddy for the same hostname
Add this site block to /etc/caddy/Caddyfile. The site address matches the DNS name. The upstream is the app’s loopback address and port as seen from Caddy. Caddy reverse_proxy examples · Caddy service configuration
app.lab.example.com {
tls internal
reverse_proxy 127.0.0.1:8080
}
Reload the official Caddy service after saving the file. Caddy service configuration
sudo systemctl reload caddy
With tls internal, Caddy issues the certificate from its own CA. On the official systemd service, get the root certificate from /var/lib/caddy/.local/share/caddy/pki/authorities/local/root.crt. Install it in the trust store used by each LAN or VPN browser that will open the app. Caddy TLS directive · Caddy local HTTPS with systemd
For clients that need a publicly trusted certificate, Caddy can use the ACME DNS challenge for a domain you control. The challenge checks authoritative DNS for a specific TXT record, so the CA can issue a certificate without inbound access to Caddy. Caddy DNS challenge
Route VPN traffic to Pi-hole and Caddy
On the Linux subnet router, enable IPv4 forwarding if it is disabled. Keep the firewall’s default forwarding policy set to deny. On most Linux systems with /etc/sysctl.d, use the following commands. Tailscale IP forwarding instructions
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
Advertise routes for both hosts. If the router already advertises other routes, include those routes in the comma-separated list. If the routes still need approval, open Machines in the Tailscale admin console, select the router, and approve both routes in Subnets. Select Save. Tailscale route advertisement and approval
sudo tailscale set --advertise-routes=192.168.50.53/32,192.168.50.10/32
If your tailnet policy needs rules for these destinations, add the two objects below to its grants array in Access controls. Replace group:homelab with an existing group authorized to use the app. With source NAT enabled, the default for Tailscale subnet routes, the hosts see the traffic as coming from the subnet router. Tailscale subnet routing and access rules · Tailscale grants syntax
[
{
"src": ["group:homelab"],
"dst": ["192.168.50.53"],
"ip": ["udp:53", "tcp:53"]
},
{
"src": ["group:homelab"],
"dst": ["192.168.50.10"],
"ip": ["tcp:443"]
}
]
On a Linux VPN client, enable use of the advertised routes. Tailscale client route settings
sudo tailscale set --accept-routes
Send the lab domain to Pi-hole over Tailscale
In the Tailscale admin console, open DNS and choose Add nameserver → Custom. Enter 192.168.50.53, enable Restrict to search domain, enter lab.example.com, and save. This nameserver applies to matching queries such as app.lab.example.com. Tailscale setup steps · Tailscale restricted nameservers
On the VPN client, enable Use Tailscale DNS settings or use the CLI below. If you use an exit node, it handles DNS by default. Enable Use with exit node for this nameserver if the client should keep using it with the exit node active. Tailscale client preferences · Tailscale exit-node DNS settings
tailscale set --accept-dns=true
Verify DNS and HTTPS separately
On the LAN, then from another network with Tailscale connected, query Pi-hole directly using a client with dig. The example should return 192.168.50.10. If the direct query works at home but times out on the VPN, check the route to Pi-hole and access to its DNS port. Cloudflare direct resolver queries · Tailscale subnet router guide
dig app.lab.example.com @192.168.50.53
Next, check the client’s normal DNS path. On macOS, Tailscale recommends the native lookup below for split DNS. Expect the same address. If the direct query works but this lookup fails on the VPN, check that the client accepts Tailscale DNS and that the restricted domain matches the hostname. Tailscale DNS tests
dscacheutil -q host -a name app.lab.example.com
From another network with the VPN off, query both public address record types. Compare the answers with the public row in the table. Cloudflare DNS resolver troubleshooting · BIND dig manual
dig @1.1.1.1 app.lab.example.com A
dig @1.1.1.1 app.lab.example.com AAAA
Back on the LAN or connected to Tailscale, open https://app.lab.example.com/ in a browser that trusts Caddy’s CA. If it fails, use the two curl commands below with the copied root.crt in your working directory. The second command supplies the proxy IP directly for that host and port while using the same HTTPS URL. Caddy local HTTPS with systemd · curl manual
curl --cacert root.crt https://app.lab.example.com/
curl --cacert root.crt --resolve app.lab.example.com:443:192.168.50.10 https://app.lab.example.com/
If only the second request works, check which address the normal lookup returns. If both requests time out over the VPN, check the route and the tailnet access rules for Caddy. If curl reports a certificate error, check the root certificate and confirm the URL’s hostname matches the Caddy site’s hostname. curl manual · Tailscale subnet router guide · Caddy TLS directive
If Caddy responds but the app does not load, check the upstream address and port in reverse_proxy. Caddy reverse_proxy examples
Evidence and limits. Pi-hole v6, Caddy v2, Tailscale, Cloudflare, BIND 9, and curl documentation was checked on November 26, 2026. The steps were documented without a lab run.