1. The problem I’m having:
TL;DR: I want caddy to manage unbound host overrides to set local DNS entries. Question is there module / way to invoke a hook script?
I just found out that you can set a unbound host overrides via api on opnsens:
curl -X POST -d \
'{"host":{"enabled":"1","hostname":"test","domain":"testdomain.com","rr":"A","mxprio":"","mx":"","server":"10.0.1.1","description":""}}' \
-H "Content-Type: application/json" \
-u ${key}:${secret} \
https://opnsense.local/api/unbound/settings/add_host_override
And my fist Idea was to use this in combination with caddy. It would be awesome to be able to set local dns entries using caddy. But I don’t really know how I could do this. I searched and the only thing remotely close to it was this: Use Caddy for local HTTPS (TLS) between front-end reverse proxy and LAN hosts
But I would need some post DNS creation hook that sends the request to opnsense, but I haven’t found anything related to this. But I may also just don’t know what I need to search for.
Is there anything that I can use to do this? Or would I need to write a module to do so and where would I need to begin?
2. Error messages and/or full log output:
None
3. Caddy version:
2.10.0
4. How I installed and ran Caddy:
docker-compose
a. System environment:
docker
b. Command:
docker compose up
c. Service/unit/compose file:
FROM caddy:2-builder AS builder
RUN xcaddy build \
--with github.com/caddy-dns/porkbun \
--with github.com/mholt/caddy-dynamicdns \
--with github.com/mietzen/caddy-dynamicdns-cmd-source
FROM caddy:2
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
name: caddy
services:
caddy:
build: .
restart: unless-stopped
cap_add:
- NET_ADMIN
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- /opt/docker/caddy/conf:/etc/caddy
- caddy_data:/data
- caddy_config:/config
networks:
- caddy
volumes:
caddy_data:
caddy_config:
networks:
caddy:
name: caddy
external: true
d. My complete Caddy config:
Does not exist at this point