diff --git a/Caddy/.env b/Caddy/.env new file mode 100644 index 0000000..1a5344a --- /dev/null +++ b/Caddy/.env @@ -0,0 +1,2 @@ +CF_API_TOKEN=1ufPvdNumd2MJd9jBQmPSPLRweLu_VrNgcW1shxy +CF_EMAIL=your@email.com \ No newline at end of file diff --git a/Caddy/Caddyfile b/Caddy/Caddyfile new file mode 100644 index 0000000..eaf6f22 --- /dev/null +++ b/Caddy/Caddyfile @@ -0,0 +1,32 @@ +{ + admin 0.0.0.0:2019 +} + +*.jimsgarage.co.uk { + tls { + dns cloudflare {env.CF_API_TOKEN} + propagation_delay 2m + resolvers 1.1.1.1 + } + + @caddy host caddy.jimsgarage.co.uk + handle @caddy { + root * /usr/share/caddy + php_fastcgi localhost:80 + file_server + } + + @trueNAS host truenas.jimsgarage.co.uk + handle @trueNAS { + reverse_proxy 192.168.6.2:80 + } + + @portainer host caddy-portainer.jimsgarage.co.uk + handle @portainer { + reverse_proxy https://portainer:9443 { + transport http { + tls + tls_insecure_skip_verify + } + } +} \ No newline at end of file diff --git a/Caddy/Dockerfile b/Caddy/Dockerfile new file mode 100644 index 0000000..1550cea --- /dev/null +++ b/Caddy/Dockerfile @@ -0,0 +1,8 @@ +# For prod you'd want to pin the version: e.g., 2.9.1-builder +FROM caddy:builder AS builder + +RUN xcaddy build \ + --with github.com/caddy-dns/cloudflare +FROM caddy:latest + +COPY --from=builder /usr/bin/caddy /usr/bin/caddy \ No newline at end of file diff --git a/Caddy/docker-compose.yaml b/Caddy/docker-compose.yaml new file mode 100644 index 0000000..fe48e34 --- /dev/null +++ b/Caddy/docker-compose.yaml @@ -0,0 +1,33 @@ +services: + caddy: + build: + context: . + dockerfile: Dockerfile + container_name: caddy + restart: unless-stopped + env_file: + - .env + environment: + - CLOUDFLARE_EMAIL=${CF_EMAIL} + - CLOUDFLARE_API_TOKEN=${CF_API_TOKEN} + - ACME_AGREE=true + ports: + - 2019:2019 # remove if you do not want admin API + - 80:80 + - 443:443 + volumes: + - caddy-config:/config + - caddy-data:/data + - ./Caddyfile:/etc/caddy/Caddyfile + - ./index.html:/usr/share/caddy/index.html + networks: + - caddy # add other containers onto this network to use dns name + +volumes: + caddy-config: + caddy-data: + +# create this first before running the docker-compose - docker network create caddy +networks: + caddy: + external: true \ No newline at end of file diff --git a/Caddy/index.html b/Caddy/index.html new file mode 100644 index 0000000..b6fc4c6 --- /dev/null +++ b/Caddy/index.html @@ -0,0 +1 @@ +hello \ No newline at end of file