How to configure Cloudflare?

My domain is mysmarthome.network and I’m trying to create the subdomains of whoami.mysmarthome.network, wiki.mysmarthome.network, etc. Sorry for redacting that in the earlier posts: in other forums, reddits, etc. I had read many posts saying it’s bad to post your domain for everyone to see.

Here are my configs:

Dockerfile

ARG CADDY_VERSION=2.5.2
FROM caddy:${CADDY_VERSION}-builder AS builder

RUN xcaddy build \
    --with github.com/lucaslorentz/caddy-docker-proxy/plugin \
    --with github.com/caddy-dns/cloudflare

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

CMD ["caddy", "docker-proxy"]

Built with: docker build -t caddy-docker-proxy--mysmarthome_network .

docker-compose.yml for caddy

version: "3.7"

services:
  caddy:
    image: caddy-docker-proxy--mysmarthome_network:latest
    ports:
      - "80:80"
      - "443:443"
    networks:
      - proxy
    env_file: .env
    environment:
      - CADDY_INGRESS_NETWORKS=proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /docker-services/caddy/data:/data
      - /docker-services/caddy/config:/config
      - /docker-services/caddy/logs:/var/log/caddy
    deploy:
      labels:
        caddy.debug:
        caddy.log.output: file /var/log/caddy/caddy.log
        caddy.acme_dns: "cloudflare {env.CF_API_TOKEN}"
        caddy.email: "{env.EMAIL}"
      placement:
        constraints:
          - node.role == manager
      replicas: 1
      resources:
        reservations:
          cpus: "0.1"
          memory: 200M
      restart_policy:
        condition: any

networks:
  proxy:
    external: true

Deployed with: docker stack deploy -c docker-compose.yml caddy

A couple test containers are:

docker-compose.yml for whoami

version: "3.7"

services:

  whoami:
    image: jwilder/whoami
    networks:
      - proxy
    deploy:
      labels:
        caddy: whoami.mysmarthome.network
        caddy.reverse_proxy: "{{upstreams 8000}}"

networks:
  proxy:
    external: true

docker-compose.yml for wikijs

version: "3.7"

services:
  wikijs:
    image: lscr.io/linuxserver/wikijs:latest
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/New_York
    volumes:
      - /docker-services/wikijs/config:/config
      - /docker-services/wikijs/data:/data
    ports:
      - 3000:3000
    networks:
      - proxy
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
      labels:
         caddy: wiki.mysmarthome.network
         caddy.reverse_proxy: "{{upstreams 3000}}"

networks:
  proxy:
    external: true
1 Like