Giter Club home page Giter Club logo

cfhookbash's Introduction

Cloudflare dns-01 challenge hook bash for dehydrated

If you like this project, or use it, please, star it!

Cloudflare Bash hook for dehydrated.

CI / CD Status
Travis Build Status
Docker

Why Cloudflare? What is this script?

If you cannot solve the HTTP-01 challenge, you need to solve the DNS-01 challenge. Details here.

With use of Cloudflare API (valid also on free plan!), this script will verify your domain putting a new record with a special token inside DNS zone. At the end of Let's Encrypt validation, that record will be deleted.

Depends on jq: sudo apt get install -y jq

You only need:

  1. Register on Cloudflare (it works also on free plan)
  2. Change your domain DNS to manage them in Cloudflare (follow their guide).
  3. Run dehydrated with this hook (or run Docker image, see below)

You will find the certificates in the folder of dehydrated.

Classic mode: Prerequisites

cfhookbash has some prerequisites:

Classic mode: Setup

cd ~
git clone https://github.com/sineverba/cfhookbash.git

Classic mode: Configuration

  1. Create a file domains.txt in the folder of dehydrated
  2. Put inside a list (one for line) of domains that need certificates.
www.example.com
home.example.net
[...]
  1. Move to the folder of cfhookbash
  2. Copy config.default.sh to config.sh
  3. Edit config.sh. To get values:
Value Where to find
Zone ID Main page domain > Right Column > API section
Global API Key Account > My Profile > API Tokens > Api Keys > Global API Key

Classic mode: Usage

Make a first run with CA="https://acme-staging-v02.api.letsencrypt.org/directory" placed in a config file in root directory of dehydrated.

./dehydrated -c -t dns-01 -k '${PATH_WHERE_YOU_CLONED_CFHOOKBASH}/cfhookbash/hook.sh'

You will find the certificates inside ~/dehydrated/certs/[your.domain.name.

Classic mode: Post deploy

You can find in hook.sh a recall to another file (deploy.sh). Here you can write different operation to execute AFTER every successfull challenge.

There is a stub file deploy.config.sh.

Usage:

copy deploy.config.sh deploy.sh && rm deploy.config.sh && nano deploy.sh

Classic mode: Cronjob

Remember that some action require sudo privilege (start and stop webserver, e.g.).

Best is run as root and running in cronjob specify full paths.

Following script will run every monday at 4AM and will create a log in home folder.

$ sudo crontab -e

0 4 * * 1 cd /home/YOUR_USER/dehydrated && /home/YOUR_USER/dehydrated/dehydrated -c -t dns-01 -k '/home/YOUR_USER/dehydrated/hooks/cfhookbash/hook.sh' >> /home/YOUR_USER/cfhookbash.log

Update / upgrade

  • Move to folder where you downloaded it
  • Type git checkout master && git pull

Commons error messages

Error Body Solution
7003 { "code": 7003, "message": "Could not route to /zones/dns_records, perhaps your object identifier is invalid?" }, { "code": 7000, "message": "No route for that URI" } Check your Zone ID value. Probably is wrong.

Contributing

Everyone is welcome to contribute! See CONTRIBUTING.md

Contributors, credits and bug discovery :)

  • YasharF
  • Ramblurr

Inspired by


Docker mode - beware! Not stable and under development!

  • Make a new dir (e.g. mkdir -p /home/$USER/cfhookbashdocker)
  • Create a /certs folder
  • Create a /config folder
  • Create a config.sh file in /config/ and fill it (see below how to get data)
  • Create a domains.txt file in /config/ and insert a domain for every line
  • Make a first run in stage mode: create a config file under /config with this content CA="https://acme-staging-v02.api.letsencrypt.org/directory"

Run

docker run -it \
  -v ${PWD}/certs:/certs \
  -v ${PWD}/config:/config \
  --name cfhookbash \
  sineverba/cfhookbash:latest
  • Certs will be available in /certs
  • Docker run a cronjob every minute

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.