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.

Revisions

  1. LachlanArthur created this gist Mar 13, 2025.
    22 changes: 22 additions & 0 deletions compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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: {}
    32 changes: 32 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    First run: create caddy network for other stacks to attach to:
    ```sh
    docker network create caddy
    ```

    Start the proxy
    ```sh
    docker compose up
    ```

    ---

    Integrating with other stacks:

    Add the external network:
    ```yml
    networks:
    caddy:
    external: true
    ```
    Add the `caddy` network and labels to the services you want to proxy:
    ```sh
    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.
    ```