Add dns entry to Opensense / Hooks? - Help - Caddy Community
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 override…
Add dns entry to Opensense / Hooks? - Help - Caddy Community = 40rem)" rel="stylesheet" data-target="chat_desktop" /> = 40rem)" rel="stylesheet" data-target="discourse-reactions_desktop" /> = 40rem)" rel="stylesheet" data-target="poll_desktop" /> = 40rem)" rel="stylesheet" data-target="desktop_theme" data-theme-id="1" data-theme-name="caddy custom"/> Add dns entry to Opensense / Hooks? Help mietzen (Nils) August 20, 2025, 1:50pm 1 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 OPNsense DNS Module mietzen (Nils) August 20, 2025, 1:54pm 2 Oh I think I can answer my own question: I going to test this. Edit: This is totally doable I love caddy You need this module: GitHub - mholt/caddy-events-exec: Run commands on Caddy events Caddyfile: events { on cert_obtained exec echo "MY DOMAIN: {event.data.identifier}" } Log: 2025/08/20 14:15:46.226 INFO tls.obtain releasing lock {"identifier": "sub.example.com"} MY DOMAIN: sub.example.com For anyone who is curious, what event.data looks like: map[ certificate_path:certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.sub.example.com/wildcard_.sub.example.com.crt csr_pem:[10 11 ...] identifier: sub.example.com issuer:acme-v02.api.letsencrypt.org-directory metadata_path:certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.sub.example.com/wildcard_.sub.example.com.json private_key_path:certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.sub.example.com/wildcard_.sub.example.com.key renewal:false storage_path:certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.sub.example.com ]