Skip to content

Instantly share code, notes, and snippets.

@LachlanArthur
Created March 13, 2025 14:49
Show Gist options
  • Save LachlanArthur/56382c6d2cb0e439219808dfb957da7f to your computer and use it in GitHub Desktop.
Save LachlanArthur/56382c6d2cb0e439219808dfb957da7f to your computer and use it in GitHub Desktop.
Caddy Docker Proxy

First run: create caddy network for other stacks to attach to:

docker network create caddy

Start the proxy

docker compose up

Integrating with other stacks:

Add the external network:

networks:
  caddy:
    external: true

Add the caddy network and labels to the services you want to proxy:

services:
  app:
    networks:
      - default
      - caddy
    labels:
      caddy: example.localhost # The domain this app should use.
      caddy.reverse_proxy: "{{upstreams 80}}" # The internal port that the container is listening on.
version: "3.7"
services:
caddy:
image: lucaslorentz/caddy-docker-proxy:ci-alpine
ports:
- 80:80
- 443:443
environment:
- CADDY_INGRESS_NETWORKS=caddy
networks:
- caddy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- caddy_data:/data
restart: unless-stopped
networks:
caddy:
external: true
volumes:
caddy_data: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment