Help getting caddy to run at boot [SOLVED]

1. Caddy version (caddy version):

v2

2. How I run Caddy:

sudo caddy start

a. System environment:

4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
No docker.

b. Command:

sudo caddy start

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

jellycloud.netlib.re {
    encode gzip
        log {
            output file /home/jellycloud/caddy/logs/jellyfin_access.log {
                roll true               # Rotate logs, enabled by default
                roll_size_mb 5          # Set max size 5 MB
                roll_gzip true          # Whether to compress rolled files
                roll_local_time true    # Use localhost time
                roll_keep 2             # Keep at most 2 log files
                roll_keep_days 7        # Keep log files for 7 days
            }
        }
    reverse_proxy localhost:8096
}
# Edit 05/06/20 Remove Empty Brackets, Change logging format, and added Email portion. Commented out email portion for now
# Edit 05/07/20 Removed Email portion. Adding an optional part in the guide for it.

3. The problem I’m having:

The only way I can get caddy to work is by running:
sudo caddy start
It doesn’t start automatically at boot, which is what I need it to do. I have tried putting this command in /etc/rc.local, but it does not work. I have done all kinds of things, following all kinds of blogs and documentation trying to install configure and run caddy. I couldn’t possibly remember all the details at this point! I was just kind of flailing about, and eventually it worked: I got a certificate, and I can access my jellyfin server over https at the main url. But the ONLY way it works is if I type sudo caddy start.

4. Error messages and/or full log output:

I’m not sure what’s expected here. Caddy starts when I tell it to, but doesn’t seem to work or work right after reboot.

5. What I already tried:

I have done all kinds of things, following all kinds of blogs and documentation trying to install configure and run caddy. I couldn’t possibly remember all the details at this point! I was just kind of flailing about, and eventually it worked: I got a certificate, and I can access my jellyfin server over https at the main url. But the ONLY way it works is if I type sudo caddy start.

6. Links to relevant resources:

Welcome @mikqu

Thanks for filling out the info. Since you’re running Ubuntu, the easiest way to get Caddy to run at boot is to install the package: Install — Caddy Documentation - this will automatically download, install, and start Caddy with a default config that you can then replace with your own. Please note that you will have to know the basics of using systemd, which is outside the scope of our docs.

Actually, our docs do explain it somewhat, since we also have manual install instructions if you want to have a better understanding of what is going on: Install — Caddy Documentation

Check out those resources. They should answer your question.

1 Like

Thanks for the reply. I did install the package. I think where I got lost was in trying to customize the default configs. I can’t remember in what exact way I was failing, but as I said, there are so many moving parts, and I was kind of flailing about. I’m afraid to go through that whole ‘process’ again, since in the end I sort of have it working. The server is a VPS, so I suppose anytime I have to reboot it, I’ll be in the terminal to manually start caddy too. If that pain ever exceeds the pain of diving back into caddy configs, I’ll take another crack at it!

The quick (and dirty) way with crontab:

sudo crontab -e

Add this line:

@reboot caddy start --config /path/to/Caddyfile

1 Like

Thank you so much! I don’t know why that worked when rc.local didn’t… but I am very used to not understanding :smiley: Linux is dark and mysterious magic!

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