12
you are viewing a single comment's thread
view the rest of the comments
[-] SidewaysHighways@lemmy.world 2 points 4 days ago

What is the best way to have caddy run at boot with env file, without running as root?

[-] anzo@programming.dev 2 points 4 days ago

Create a user, and then a systemd unit for it, under ~/.config/systemd/user/ with contents like these:

[Unit]
Description=Caddy web server
After=network.target

[Service]
ExecStart=/usr/local/bin/caddy run --config /path/to/Caddyfile --envfile /path/to/Envfile
ExecReload=/usr/local/bin/caddy reload --config /path/to/Caddyfile --envfile /path/to/Envfile
Restart=on-failure
User=caddy
Group=caddy

[Install]
WantedBy=default.target

Adjust the paths in the arguments. It will require systemctl daemon-reload for such unit to be available for enabling and starting it...

load more comments (1 replies)
this post was submitted on 22 Sep 2024
12 points (100.0% liked)

Linux

4992 readers
205 users here now

A community for everything relating to the linux operating system

Also check out !linux_memes@programming.dev

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 1 year ago
MODERATORS