Noob having issues running Duck DNS module for Caddy

1. The problem I’m having:

Unable to run caddy.service, “systemctl status caddy” shows an error as follows:

“Error during parsing: getting module named ‘dns.providers.duckdns’: module not registered: dns.providers.duckdns”

2. Error messages and/or full log output:

> Jul 06 10:08:30 raspberrypi caddy[16346]: LANG=en_DK
> Jul 06 10:08:30 raspberrypi caddy[16346]: LANGUAGE=en_DK
> Jul 06 10:08:30 raspberrypi caddy[16346]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
> Jul 06 10:08:30 raspberrypi caddy[16346]: NOTIFY_SOCKET=/run/systemd/notify
> Jul 06 10:08:30 raspberrypi caddy[16346]: HOME=/var/lib/caddy
> Jul 06 10:08:30 raspberrypi caddy[16346]: LOGNAME=caddy
> Jul 06 10:08:30 raspberrypi caddy[16346]: USER=caddy
> Jul 06 10:08:30 raspberrypi caddy[16346]: INVOCATION_ID=6528405368494e6f83c52988a98dbaa6
> Jul 06 10:08:30 raspberrypi caddy[16346]: JOURNAL_STREAM=8:65948
> Jul 06 10:08:30 raspberrypi caddy[16346]: {"level":"info","ts":1688630910.8086872,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
> Jul 06 10:08:30 raspberrypi caddy[16346]: Error: adapting config using caddyfile: parsing caddyfile tokens for 'tls': /etc/caddy/Caddyfile:4 - Error during parsing: getting module named 'dns.providers.duckdns': module not registered: dns.providers.duckdns
> Jul 06 10:08:30 raspberrypi systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
> Jul 06 10:08:30 raspberrypi systemd[1]: caddy.service: Failed with result 'exit-code'.
> Jul 06 10:08:30 raspberrypi systemd[1]: Failed to start Caddy.

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

First I installed Caddy, as per usual

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

Then I fetched the Duck DNS module with xcaddy, after fumbling to get Go to work for a couple of hours…

xcaddy build --with https://github.com/caddy-dns/duckdns

I attempted to do the update-alternative procedure, without luck.

Running ‘systemctl start caddy’ gives the error shown in the start.

a. System environment:

Raspberry Pi 4 Model B, with Raspbian newest version.

b. Command:

systemctl start caddy

c. Service/unit/compose file:

d. My complete Caddy config:

jellyfinlynge12.duckdns.org {
        reverse_proxy 192.168.0.204:8096
        tls {
                dns duckdns (my token)
        }
}

I have tried several re-arrangements, without further luck. This is just the most recent I attempted, with inspiration from DemonWarriorTech’s YouTube video

5. Links to relevant resources:

n/a

Did you actually move the build binary to the correct location?

You followed these instructions Build from source — Caddy Documentation ?

Run /usr/bin/caddy.custom list-modules, you should see the duckdns module. If you don’t, then you didn’t move the built binary to the correct location.

Did you actually move the build binary to the correct location?
You followed these instructions Build from source — Caddy Documentation ?

I do not understand these instructions fully, sorry. Especially: “Your custom caddy binary should be located in the current directory.” What’s the “current” directory? /usr/bin/caddy ?

Run /usr/bin/caddy.custom list-modules , you should see the duckdns module. If you don’t, then you didn’t move the built binary to the correct location.

Standard modules: 100

dns.providers.duckdns

Non-standard modules: 1

It isn’t named “duckdns” as you’ve pointed out, but rather “dns.providers.duckdns”. I don’t understand, do I need to rename it? I’m pretty lost…

Your current directory is wherever you are in your terminal at the moment you run the command. Run the pwd command to see your “present working directory”.

No, that’s correct. The full name of the module is dns.providers.duckdns but in your config you just do dns duckdns because the dns module knows to look for dns.providers.<provider-name> when finding modules.

If /usr/bin/caddy.custom does has duckdns as expected, then it should be working. Did you do the rest of the update-alternatives commands to make sure that version of the binary is active? Make sure to restart your systemd service after doing that so it loads the correct binary.

Okay, thanks for the help so far, I’ve narrowed it down to dpkg-divert and update-alternatives giving me issues:

benji@raspberrypi:~ $ sudo dpkg-divert --divert /usr/bin/caddy.default --rename /usr/bin/caddy
dpkg-divert: error: 'local diversion of /usr/bin/caddy to /usr/bin/caddy.default' clashes with 'local diversion of /usr/local/caddy to /usr/bin/caddy.default'
benji@raspberrypi:~ $ sudo mv ./caddy /usr/bin/caddy.custom
benji@raspberrypi:~ $ sudo update-alternatives --install /usr/bin/caddy caddy /usr/bin/caddy.default 10
update-alternatives: error: alternative path /usr/bin/caddy.default doesn't exist
benji@raspberrypi:~ $ sudo update-alternatives --install /usr/bin/caddy caddy /usr/bin/caddy.custom 50
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/caddy.custom because link group caddy is broken
update-alternatives: warning: not replacing /usr/bin/caddy with a link
benji@raspberrypi:~ $ update-alternatives --config caddy
There is only one alternative in link group caddy (providing /usr/bin/caddy): /usr/bin/caddy.custom
Nothing to configure.
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/caddy.custom because link group caddy is broken
update-alternatives: error: error creating symbolic link '/etc/alternatives/caddy.dpkg-tmp': Permission denied

Ah, you should remove /usr/local/caddy, you shouldn’t have anything there.

Re-run every command after that point, once you’ve removed that file.

Okay, so there wasn’t any ''caddy" folder located in /usr/local, so I created it myself and… That seems to have done the trick! All the pdkg commands succeeded, which means the Caddy process runs like butter now, so thank you so much for your assistance.

I see how much work you’ve put into this and helping individuals on the forums, and I want to let you know it is greatly appreciated. I wish you a very pleasant day :smiley:

1 Like

There should not be anything at /usr/local/caddy. That’s not a path we use or documented anywhere. I’m not sure where you got that from.

:sweat_smile: That’s peculiar, the only other thing I can think of is that I removed the lines “/usr/bin/caddy
/usr/bin/caddy.default” from /var/lib/dpkg/diversions out of curiousity and added them again. Perhaps there was a typo I missed…? Other than that, I’m not really sure what I did differently.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.