Running Caddy as an interactive foreground process is fine for testing, but in production you want it managed by systemd so it starts automatically on boot, restarts if it crashes, and integrates with the system logging infrastructure. This guide walks through manually registering the NaïveProxy Caddy binary as a systemd service — no package manager installation required.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/klzgrad/naiveproxy/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
- A
caddybinary built with the NaïveProxy fork of the forwardproxy plugin (see Caddy Setup) systemctl --version>= 232sudoprivileges on the target machine
Make the binary executable and move it to a system-wide location on
$PATH. Then create the Caddy configuration directory and move your Caddyfile into it:Before installing the service, verify that Caddy starts successfully with the configuration file. This will catch any Caddyfile syntax errors and confirm that certificate issuance works:
groupadd --system caddy
useradd --system \
--gid caddy \
--create-home \
--home-dir /var/lib/caddy \
--shell /usr/sbin/nologin \
--comment "Caddy web server" \
caddy
The
--system flag creates a low-UID service account. The --shell /usr/sbin/nologin flag prevents interactive logins. Caddy stores its automatic TLS certificates in its home directory (/var/lib/caddy), which is why --create-home is needed.[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
Double-check that the paths in
ExecStart and ExecReload exactly match where you placed the caddy binary and Caddyfile. If either path is wrong, the service will fail to start or fail to reload. Use which caddy to confirm the binary location.After=network-online.target / Requires=network-online.target — Ensures the service only starts once the network is fully up, which is necessary for Let’s Encrypt certificate issuance on first boot.AmbientCapabilities=CAP_NET_BIND_SERVICE — Grants the caddy user permission to bind to privileged ports (443) without running as root.LimitNOFILE=1048576 — Raises the open file descriptor limit to handle many concurrent connections.PrivateTmp=true / ProtectSystem=full — Sandbox the process to reduce the impact of any security vulnerabilities.ExecReload — Allows systemctl reload caddy to apply configuration changes without a full restart and without dropping existing connections.Ongoing Management
Reload after a config change (graceful, no connection drops):Next Steps
- If you have not yet written your Caddyfile, see Caddy Setup.
- For the HAProxy-based frontend alternative, see HAProxy Setup.