FreeBSD Init-Script for the Caddy Webserver

published on on Caddy, Webserver, FreeBSD

I have used Caddy for a while now on FreeBSD. But though it lacks a working init script, I decided to write one on my own. Here's the result, description below:

Init script

UPDATE 2016/03/20: My FreeBSD init script has made it into the official Caddy repository:

Please take notice, that Caddy currently only runs as root user because it does not support privilege de-escalation yet, so you might wanna jail your webserver.

There's the link as well: [ ( "FreeBSD init script for the Caddy webserver on GitHub Gists")


It exposes multiple configuration variables, which may be set in /etc/rc.conf:

  • caddy_enable: As usual, must be set to YES in order for Caddy to start at boot time
  • caddy_cert_email: HTTPS certificate issuer email address ( - the init script automatically sets -agree so be sure you agree the terms of usage. This information is mandatory.
  • caddy_bin_path: The path to the caddy binary. Defaults to /usr/local/bin/caddy
  • caddy_cpu: Amount of CPU that Caddy might use. Default is 100% but I reset it to 99% because otherwise Caddy regularly killed my webserver jail
  • caddy_config_path: Path to the Caddyfile, defaults to /usr/local/www/Caddyfile


The following files are created:

  • /var/log/caddy.log: Caddy log file
  • /var/run/ Caddy pid file

The init script uses / as the working directory, so certificates go to /.caddy.


Do the following things as root:

  • Download Caddy from and copy the binary to /usr/local/bin/caddy
  • chmod +x it
  • Copy the init script from above to /usr/local/etc/rc.d/caddy and chmod +x it
  • run sysrc caddy_enable=YES
  • run sysrc cadddy_cert_email='youremailaddress'
  • Place a Caddyfile in /usr/local/www/ (docs:
  • run service caddy start