Getting started with Caddy

Recently I’ve been enjoying using Caddy web server to get automatic-HTTPS websites. I took the time to package it for Fedora and CentOS/RHEL to make it more accessible and more maintainable. This guide demonstrates how to use those packages.

By Sean MacEntee (CC BY 2.0), via Wikimedia Commons


In order for Caddy to provision your Let’s Encrypt certificates as soon as it starts, you will need two things configured beforehand.

  • a DNS record pointing your domain to your server’s IP address
  • port 80 allowed for the ACME HTTP challenge

Since you’ll need port 443 open later anyways, just go ahead and open both now.

firewall-cmd --permanent --add-service=http --add-service=https
firewall-cmd --reload

For the rest of the guide, make sure you replace with the actual domain name you want to use.


CentOS and RHEL (make sure EPEL is enabled first):

yum install caddy


dnf install caddy


Put your own content in /var/www/, or use this example index file to get started now and swap in your own content later.

mkdir -p /var/www/
echo '<h1>Hello world!</h1>' > /var/www/

If you care about selinux (you should), restore the file context for your content files and directories.

restorecon -r /var/www


Create a Caddyfile as /etc/caddy/conf.d/ Files in /etc/caddy/conf.d ending in .conf will be automatically imported by the global Caddyfile /etc/caddy/caddy.conf, which in turn is read by the systemd service unit. {
root /var/www/


Enable and start the Caddy daemon.

systemctl enable --now caddy


You should now be able to open in your browser and view your content.