Caddy is a powerful web server that automatically manages HTTPS: point a domain at your machine, write three lines in a Caddyfile, and the site is live on TLS. On bare metal, it fronts static sites, PHP apps or Node and Python backends, with no SSL scripts to maintain. This guide covers each installation method, from the official Caddy package to Docker, then commands, testing, upgrades and security, with support for every common platform. New to bare metal hosting? Our hosting guide for beginners covers the basics. Plans begin at $11.10/month.
Key Takeaways
- The official package is the easiest approach: you get a systemd service, a dedicated user and security fixes through normal system updates.
- Certificates need a domain pointing at the server IP, web traffic allowed in, and no other web server listening on ports 80 and 443.
- Edit one configuration file, then reload Caddy: no downtime.
- Tools required: SSH access with sudo, a domain name, and about 15 minutes.
Overview of Caddy and Why Use It on a Dedicated Server
This open-source, enterprise-ready software project is written in Go and shipped as one static binary, with source code on GitHub and documentation on caddyserver.com. It obtains and renews certificates from Let's Encrypt or ZeroSSL through the ACME protocol, with no cron job, and its community forum answers most questions.
It fits three roles on a dedicated machine:
- File server for static sites built with Hugo, Astro or plain HTML.
- Reverse proxy in front of an application: Node, Python, Go, or PHP through php-fpm.
- TLS front end for many domains on one public IP, with HTTP/3 support built in and visitor privacy protected by default.
Its config file stays short: forwarding a site to an app takes two lines, with headers and WebSockets handled for you, and solid performance out of the box. That is the main difference from a manual NGINX installation, where certificates come from a separate Certbot setup.
Prerequisites: OS, Root Access, and Required Packages
- A Linux host. Ubuntu 24.04 and AlmaLinux 9 are among the templates in the control panel, and both support Caddy.
- Root access, or a sudo user.
- A domain name with a DNS record of type A (and AAAA for IPv6) set to the server IP. Automatic HTTPS cannot sign a certificate for a bare IP address.
- Configure the server to accept ports 80 and 443. Our firewall configuration guide covers the rules.
- No other web server set to listen on ports 80 or 443, since Caddy needs to listen there itself. Stop Apache or Nginx first; if you are still choosing between those two, our comparison of NGINX and Apache weighs them.
Installing Caddy on Debian/Ubuntu
The recommended approach uses the Cloudsmith repository. Follow these instructions in order.
Step 1: install the prerequisites and add the signing key.
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpgStep 2: add the repository and make the keyring readable.
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy.list
sudo chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpgStep 3: install the package.
sudo apt update
sudo apt install caddyOnce installed, the package creates a caddy user, the systemd service, a default Caddyfile and a welcome page, and it is live as soon as it finishes.
Installing Caddy on CentOS, RHEL, and Fedora
On Fedora and RHEL-compatible systems such as AlmaLinux, Rocky Linux or CentOS Stream, Caddy comes from a community source kept current:
sudo dnf install 'dnf-command(copr)'
sudo dnf copr enable @caddy/caddy
sudo dnf install caddyUnlike with apt, the installed service is not active yet; turn it on as shown below and allow web traffic in firewalld with firewall-cmd --permanent --add-service=http --add-service=https.
Installing Caddy on Arch Linux
Arch and Manjaro ship it in their repositories: sudo pacman -Syu caddy. The same service unit comes with it.
Installing Caddy on Windows (PowerShell)
On a Windows instance, download the amd64 executable from the GitHub releases page, or use Chocolatey or Scoop. Put the config next to it and launch caddy run from PowerShell. To keep it running after you log out, register it with sc.exe create, as the documentation explains. The binary size stays small, with no dependencies.
Configuring Caddy as a Systemd Service
The Linux builds ship a unit that runs as the unprivileged caddy user, reads /etc/caddy/Caddyfile and keeps certificates in its data directory. To get Caddy to start at boot and launch it now:
sudo systemctl enable --now caddyStep 4: create a Caddyfile for your site. Next, configure Caddy by replacing the default file:
example.com {
root * /var/www/example
file_server
}
app.example.com {
reverse_proxy localhost:3000
}Each block acts as a virtual host. The first one serves static files from the path the directive names. The second forwards each request to an app on localhost port 3000, such as a Node.js backend. Make the folder named in that directive readable by the service user. For PHP, use the php_fastcgi directive pointed at the php-fpm socket instead; our guide to installing PHP with php-fpm sets up that socket.
Enabling Automatic HTTPS with ACME
There is nothing to switch on to enable HTTPS: when a site address is a hostname, Caddy requests a certificate through ACME, redirects HTTP to HTTPS and renews it before expiry. Three conditions apply:
- DNS already points the domain at the server.
- Port 80 or 443 is reachable from the internet for the challenge.
- The data directory is writable, since Caddy will store each certificate in that storage.
While testing, set the Let's Encrypt staging CA with the acme_ca global option to avoid rate limits, then remove it.
Running Caddy with Docker or Docker-Compose (optional)
If you already run each application in containers after installing Docker Engine, use the Docker image. A minimal Docker Compose file:
services:
caddy:
image: caddy:2
restart: unless-stopped
ports: ["80:80", "443:443", "443:443/udp"]
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
volumes:
caddy_data:Run docker compose up -d to bring the stack up, and keep the data volume: it holds your certificates. Point each upstream at a service name so backends stay off the public network; that approach also keeps privacy-sensitive services internal. The image tag caddy:2 follows the stable line; pin a full tag for repeatable builds, and use the builder image with xcaddy to add a module or plugin; each module extends the core. The default image is the easiest starting point.
Common Caddy Commands: start, stop, reload, status
| Action | Command |
|---|---|
| Start | sudo systemctl start caddy |
| Stop | systemctl stop caddy (as root) |
| Apply config | sudo systemctl reload caddy |
| Status | service caddy status |
| Logs | journalctl -u caddy -f |
Three CLI tools help too: caddy validate --config /etc/caddy/Caddyfile checks the file, caddy fmt --overwrite formats it, and caddy adapt shows the JSON that the Caddyfile adapter produces. JSON is the native format behind the admin API, and a reload drops no connection.
Testing Your Installation: localhost and domain verification
First, check on the server itself:
curl -I http://localhostA 200 OK from localhost confirms the service started and Caddy is running. If localhost does not answer, view the status and read the log. Then test your domain from your own computer with curl -I https://example.com. A 200 with a valid certificate means DNS, open ports and ACME all work.
Troubleshooting Common Issues
| Issue | Likely cause | Fix |
|---|---|---|
| address already in use | Apache or Nginx on 80/443 | Stop and disable it |
| No certificate | DNS not pointing at the IP, or port 80 blocked | Check DNS and the firewall |
| too many certificates | Let's Encrypt rate limit | Use the staging CA while testing |
| Permission denied | Site root not readable by caddy | Fix ownership |
| Changes ignored | Config not applied | Validate, then reload Caddy |
The journalctl -u caddy command shows the exact error for nearly every issue. Note that a typo in the config, such as a missing brace or a stray comment character, is the most common issue.
Upgrading Caddy to the Latest Stable Version
With the official source in place, updates arrive with your system updates:
sudo apt install --only-upgrade caddyUse dnf update caddy on Fedora or RHEL. Each stable release brings security fixes, and 2026 alone had several. With Docker, pull the new image and recreate the container. If you build with custom plugins, such as a DNS module, through xcaddy, rebuild against the new release, since each plugin is compiled in, and check that every plugin is still maintained.
Best Practices for Security and Performance
- Stay on the packaged version so patches arrive automatically.
- Keep the admin API local, the safest solution. It listens on
localhost:2019and can change the live configuration; disable it withadmin offif you never use it.
- Add security headers with the
headerdirective, including HSTS and a Content Security Policy.
- Compress responses with
encode zstd gzipfor better performance on every site you run.
- Allow UDP 443 for HTTP/3, on by default, for better performance and support on mobile networks.
- Log access with the
logdirective; Caddy rotates logs itself.
For a full stack around it, see our guide to website hosting on bare metal.
Conclusion: Next Steps and Resources
The server turns a Linux machine into an HTTPS web server in about 15 minutes: one package, one Caddyfile, one command. Each new site or project is a new block, renewed automatically. It is a solid solution for most web hosting projects on a cloud or bare-metal instance, managed or self-run, from a portfolio to a busy API.
FAQ
How do I install Caddy?
Add the official source, then use apt or dnf, depending on your distribution.
Can I run Caddy on Windows?
It does, as a single executable from the releases page, or through Chocolatey in PowerShell, with the same Caddyfile support on every Windows version.
How can I run Caddy as a service?
On Linux, the systemd unit ships with it: run sudo systemctl enable --now caddy. On Windows, register the executable with sc.exe create.
What is the quickest way to set up Caddy on Debian?
Follow the Debian/Ubuntu section above: signing key, source list, then the install command.
How do I upgrade Caddy on a dedicated server?
Through your normal system updates; with Docker, pull the new image.
Host your sites behind Caddy on bare metal Kimsufi dedicated servers from $11.10/month. Root access, fixed monthly pricing, built-in DDoS protection.
