Sign inSign up

starrbuck68/caddy-cloudflare

By starrbuck68

Updated about 2 years ago

Caddy with Cloudflare integration. For linux/arm64/v8 only.

Image
Networking
Web servers
0

827

starrbuck68/caddy-cloudflare repository overview

starrbuck68/caddy-cloudflare
Caddy with Cloudflare integration. For linux/arm64/v8 only.

You can obtain a Cloudflare API token using the Cloudflare Portal. To create an API token with minimal scope, use the following steps:

Log into your dashboard, go to your profile, click on API Tokens, hit Create Token, select custom token, and grant the following permissions:

  • Zone / Zone / Read
  • Zone / DNS / Edit
  • Copy down your token in a safe place.

    Add CLOUDFLARE_API_TOKEN as an environment to your Docker Compose file:

    services:
      caddy:
        image: starrbuck68/caddy-cloudflare:0.0.1
        container_name: caddy-cloudflare
        restart: unless-stopped
        cap_add:
          - NET_ADMIN
        environment:
          - CLOUDFLARE_API_TOKEN=ahdhoawhroeiqwouheriouaghoisgfhoius
        ports:
          - 80:80
          - 443:443
          - 443:443/udp
        volumes:
          - ./caddy/Caddyfile:/etc/caddy/Caddyfile
          - caddy_data:/data
          - caddy_config:/config
          - /var/www/html:/srv
    volumes:
      caddy_data:
        external: true
      caddy_config:
        external: true

    You may have to create the external caddy volumes with

    docker volume create caddy_data
    and
    docker volume create caddy_config
    This ensures the data and config is persistent between container restarts.

    You should add the following to the top of your Caddyfile. Remove the acme_ca line referencing the staging server when you are satisfied with your testing:

    {
        acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
        acme_dns cloudflare {env.CLOUDFLARE_API_TOKEN}
    }

    Then remember to add the tls directive to your site(s):

    www.yourdomain.com {
        root * /srv
        file_server
        encode gzip
        tls {
            dns cloudflare {env.CLOUDFLARE_API_TOKEN}
            resolvers 1.1.1.1 1.0.0.1
        }
    }

    Tag summary

    Content type

    Image

    Digest

    sha256:d3d66b762

    Size

    40.4 MB

    Last updated

    about 2 years ago

    docker pull starrbuck68/caddy-cloudflare