Deploy Caddy with Dokploy: Docker Compose Setup Guide
Step-by-step guide to deploying Caddy web server on your VPS using Dokploy and Docker Compose. Includes Caddyfile configuration, static file serving, and reverse proxy setup.
Deploy Caddy with Dokploy
Dokploy is an open-source server management platform that simplifies deploying Docker Compose applications on your VPS. It handles reverse proxy configuration, SSL certificates, and deployment management.
This guide covers deploying Caddy as a service within Dokploy. Since Dokploy already provides its own Traefik-based reverse proxy with automatic HTTPS, Caddy is typically deployed as an internal reverse proxy for other services, a static file server, or an API gateway — running behind Dokploy's Traefik layer.
Prerequisites
- A VPS with at least 1 vCPU, 512 MB RAM, and 5 GB storage
- Dokploy installed and running on your server (installation docs)
- A domain name (e.g.,
web.yourdomain.com) with DNS A record pointing to your server's IP
Docker Compose Configuration
Create a new Compose project in Dokploy and paste the following configuration:
version: "3.8"
services:
caddy:
image: caddy:2-alpine
restart: unless-stopped
ports:
- "8080:80"
- "2019:2019"
environment:
- CADDY_ADMIN=${CADDY_ADMIN:-off}
volumes:
- ../files/caddy-config:/config
- ../files/caddy-data:/data
- ../files/caddy-site:/srv
- ../files/caddy-caddyfile:/etc/caddy
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:80/ || exit 1"]
interval: 30s
timeout: 10s
retries: 3
Note: Caddy runs behind Dokploy's Traefik reverse proxy, so it listens on port 80 internally. Dokploy handles SSL termination via Traefik. The admin API (port 2019) is disabled by default for security — enable it only if you need dynamic configuration.
Before deploying, create a Caddyfile in your ../files/caddy-caddyfile/ directory. Here is a basic static file server configuration:
:80 {
root * /srv
file_server
encode gzip
}
Environment Variables
Set these in Dokploy's Environment tab for your compose project:
| Variable | Purpose | Example |
|---|---|---|
CADDY_ADMIN |
Admin API address (set off to disable) |
off |
In Dokploy, environment variables are set via the Environment editor in the project settings. Do not create a .env file manually — Dokploy manages this for you.
Volumes & Data Persistence
This setup uses Dokploy's ../files convention for bind-mounted volumes:
../files/caddy-config— Caddy's persisted configuration state (auto-saved JSON config)../files/caddy-data— TLS certificates, private keys, and OCSP staples (critical — must persist)../files/caddy-site— Static website files served by Caddy../files/caddy-caddyfile— Your Caddyfile configuration (mounted to/etc/caddy)
The ../files path is relative to the compose file inside Dokploy's project directory. This ensures your data persists across redeployments. The /data and /config volumes are critical — losing them means Caddy will need to re-obtain TLS certificates (if managing its own HTTPS).
If you need S3 backup support, consider using named Docker volumes instead. Named volumes can be backed up with Dokploy's built-in backup features.
Domain & SSL Setup
- In your Dokploy project, navigate to the Domains tab
- Click Add Domain and enter your domain (e.g.,
web.yourdomain.com) - Set the container port to
8080 - Enable HTTPS — Dokploy automatically provisions a Let's Encrypt SSL certificate
- Save and wait for the certificate to be issued (usually under a minute)
Dokploy's built-in Traefik reverse proxy handles TLS termination. Since Caddy runs behind Traefik, you should configure Caddy to listen on HTTP (port 80) only — Caddy's own automatic HTTPS is not needed when Dokploy manages SSL.
Verifying the Deployment
- Before deploying, ensure your Caddyfile exists in
../files/caddy-caddyfile/Caddyfileon the server - In Dokploy, go to your project's Deployments tab and click Deploy
- Watch the build logs — you should see the
caddycontainer pull and start - Check the Logs tab for the
caddyservice. Look for:serving initial configuration - Open
https://web.yourdomain.comin your browser — you should see your static site or Caddy's default page - Place HTML files in
../files/caddy-site/and they will be served immediately
Troubleshooting
Caddy shows "Caddyfile not found" error
Ensure the Caddyfile exists at ../files/caddy-caddyfile/Caddyfile on the host. The file must be named exactly Caddyfile (capital C, no extension). Create the directory and file before deploying.
Conflict between Caddy HTTPS and Dokploy Traefik
Since Dokploy manages SSL via Traefik, configure Caddy to serve HTTP only (listen on :80). Caddy's automatic HTTPS may conflict with Traefik if both try to bind ports 80/443 or obtain certificates for the same domain.
Static files not updating
Caddy caches responses. Clear your browser cache or add header Cache-Control no-cache to your Caddyfile for development. In production, use cache-busting filenames or appropriate cache headers.
Admin API not accessible
The admin API is disabled by default (CADDY_ADMIN=off) for security. To enable it, set CADDY_ADMIN=0.0.0.0:2019 and ensure port 2019 is not exposed publicly. Use it only for programmatic configuration changes.
SSL certificate not issuing Ensure your domain's DNS A record points to your server's IP and has propagated. Dokploy uses Let's Encrypt HTTP-01 challenges, so port 80 must be accessible. Check Traefik logs in Dokploy for certificate-related errors.
Learn more about Caddy in our complete overview.
Need a VPS? Hostinger VPS starts at $4.99/mo — perfect for running Caddy.
For more on Docker Compose deployments in Dokploy, see the Dokploy Docker Compose documentation.
App data sourced from selfh.st open-source directory.
Ready to get started?
Get the best VPS hosting deal today. Hostinger offers 4GB RAM VPS starting at just $4.99/mo.
Get Hostinger VPS — $4.99/mo// up to 75% off + free domain included
// related topics
fordnox
Expert VPS reviews and hosting guides. We test every provider we recommend.
// last updated: February 12, 2026. Disclosure: This article may contain affiliate links.