Introduction:
A Caddy server can work as a Reverse Proxy while also providing SSL certificates via Letsencrypt or ZeroSSL to the servers being proxied.
Prerequisites:
This project uses Ubuntu 24.04 server with Docker Compose installed.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.
PHP
services:
caddy:
image: caddy:2.10.2-alpine
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- caddy_data:/data
- ./Caddyfile:/etc/caddy/Caddyfile # Mounts your local Caddyfile into the container
- caddy_config:/config
# - /opt/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
networks:
- web # External network for public access
- proxy_network # Only connected internally, no direct external access
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
networks:
- proxy_network # Only connected internally, no direct external access
volumes:
caddy_data:
external: true
portainer_data:
external: true
caddy_config:
external: true
networks:
web:
external: true # Assumes you created a 'web' network with `docker network create web`
proxy_network:
# This makes the network accessible to other compose files/stacks
driver: bridge
external: true