Skip to content

mentimeter/caddy-storage-cf-kv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caddy Storate Cloudflare KV

Use Cloudflare KV as Caddy storage.

Caddy module name

caddy.storage.cloudflare_kv

Build custom Caddy with this storage using xcaddy

xcaddy build --with github.com/mentimeter/caddy-storage-cf-kv

Token required permissions

  • Workers KV Storage Read
  • Workers KV Storage Write

Setup Caddyfile

{
    storage cloudflare_kv {
        api_token "<TOKEN>"
        account_id "<ACCOUNT_ID>"
        namespace_id "<NAMESPACE_ID>"
    }
}

or using environment variables

{
    storage cloudflare_kv {
        api_token "{env.CLOUDFLARE_API_TOKEN}"
        account_id "{env.CLOUDFLARE_ACCOUNT_ID}"
        namespace_id "{env.CLOUDFLARE_NAMESPACE_ID}"
    }
}

which will replace {env.CLOUDFLARE_API_TOKEN}, {env.CLOUDFLARE_ACCOUNT_ID} and {env.CLOUDFLARE_NAMESPACE} with the equivalent CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_NAMESPACE environment variables at runtime.

For example, running with Cloudflare as the DNS resolver (using https://github.com/caddy-dns/cloudflare) and storage for the created TLS certificates.

{
    http_port 80
    https_port 443

    storage cloudflare_kv {
        api_token "{env.CLOUDFLARE_API_TOKEN}"
        account_id "{env.CLOUDFLARE_ACCOUNT_ID}"
        namespace_id "{env.CLOUDFLARE_NAMESPACE_ID}"
    }
}

example.org, *.example.org {
    reverse_proxy localhost:3000

    tls {
        dns cloudflare {env.CLOUDFLARE_API_TOKEN}
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages