Problems with caddy.service and additional parameters

So I am trying to do one simple thing: starting Caddy at boot.
I have tried various methods over the last 5 hours to get this done. But I simply can’t…
I have seen that there is a caddy.service to run caddy at boot. I completely followed the tutorial and it worked in principle… BUT I have to give caddy my Godaddy API Key when starting and I don’t know how to do that with that service…

So then I created a script to run caddy:

#!/bin/bash
cd /usr/local/bin
ulimit -n 8192
exec nohup sudo GODADDY_API_KEY=dLddddddd GODADDY_API_SECRET=8Gxxxxxxxxx caddy -log caddylog.log &

The script itself works! I just have to type sudo bash /usr/local/bin/startcaddy.sh and it is up and running.

But then I tried to run it at startup… And none of those methods worked:

  • call it via /etc/rc.local
  • create my own caddy.service in /etc/init.d which then calls the script
  • create another script in /etc/init which calls the script
  • trying to modify the original caddy.service to start my script
  • creating a cronjob with @reboot paramter
  • creating a cronjob which runs every 5 minutes

I am seriously out of ideas… And I am also kind of pissed rn… I did put so much time already into setting up caddy and at every personal milestone I run into problems… Am I this dumb?

What sort of errors are you getting?
Whats your output from teh script?
Whats the contents of the caddylog.log file

That API key is being passed to caddy as an environment variable. You should be able to add another Environment parameter in caddy.service, like the existing CADDYPATH one.

e.g.
Environment=GODADDY_API_KEY=dLddddddd
Environment=GODADDY_API_SECRET=8Gxxxxxxxxx

ok this then sounds easy…

should it look like this:

Environment=GODADDY_API_KEY=dLddddddd
Environment=GODADDY_API_SECRET=8Gxxxxxxxxx

?

Put those below the existing Environment line in caddy.service.

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