Skip to content

Docker & Caddy inside an instance

Run several containers behind one internal Caddy port while the platform edge handles HTTPS.

Docker and Caddy - containers behind an internal proxy

Why Docker + Caddy inside the instance

Docker isolates your services. Caddy, running on a single port such as 8080, routes between them. The platform edge handles public HTTPS, so you do not run Caddy on 80/443 and you do not need certificates in the guest.

Project structure

paths
~/apps/api/docker-compose.yml
~/apps/api/Caddyfile

Compose

yaml
services:
proxy:
image: caddy:2
restart: unless-stopped
ports: ["8080:8080"]
volumes: ["./Caddyfile:/etc/caddy/Caddyfile:ro"]
api:
image: ghcr.io/yourorg/api:latest
restart: unless-stopped
Caddyfile
:8080 {
reverse_proxy api:3000
}

Practical -- try it now

Deploy an API behind Caddy

  1. mkdir -p ~/apps/hello && cd ~/apps/hello
  2. Create docker-compose.yml and Caddyfile.
  3. Run: docker compose up -d --build
  4. In Sites, set the web origin to 8080 (or add a site) and open the HTTPS URL.
Ask a question...
Ctrl+I