DOKPLOY-GUIDE 7 min read fordnox

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

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:

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

  1. In your Dokploy project, navigate to the Domains tab
  2. Click Add Domain and enter your domain (e.g., web.yourdomain.com)
  3. Set the container port to 8080
  4. Enable HTTPS — Dokploy automatically provisions a Let's Encrypt SSL certificate
  5. 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

  1. Before deploying, ensure your Caddyfile exists in ../files/caddy-caddyfile/Caddyfile on the server
  2. In Dokploy, go to your project's Deployments tab and click Deploy
  3. Watch the build logs — you should see the caddy container pull and start
  4. Check the Logs tab for the caddy service. Look for: serving initial configuration
  5. Open https://web.yourdomain.com in your browser — you should see your static site or Caddy's default page
  6. 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.

~/self-hosted-app/caddy/dokploy/get-started

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

caddy dokploy docker compose self-hosted web server caddy deployment

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.