Halo, kalau kamu merasa tulisan saya ngebantu kamu, kamu bisa ucapkan terima kasih lewat saweria.

If you feel this website help you, you can donate at saweria.



The Problem

Error When Install New Certificate

Error When Install New Certificate

It Was Cloudflare IP, Not Your Server

It Was Cloudflare IP, Not Your Server

How can I install Let’s Encrypt when my domain behind Cloudflare Proxy?


Solution

  1. Create Cloudflare API Token with Zone:DNS:Edit permission
Zone:DNS:Edit Permission

Zone:DNS:Edit Permission

  1. Install certbot-dns-cloudflare sudo apt install python3-certbot-dns-cloudflare.

    If you got error certbot: error: unrecognized arguments: --dns-cloudflare-credentials, that mean python3-certbot-dns-cloudflare & it depedencies not installed correctly, use sudo apt install --reinstall python3-certbot-dns-cloudflare.

  2. Then create file cloudflare.ini, you can put it anywhere but We will follow documentation, it will put in ~/.secrets/certbot/cloudflare.ini

  3. mkdir -p ~/.secrets/certbot, create new file vim ~/.secrets/certbot/cloudflare.ini

#mkdir -p ~/.secrets/certbot/
#put this file in ~/.secrets/certbot/cloudflare.ini
# Cloudflare API token used by Certbot
dns_cloudflare_api_token = yourCF_API_TOKEN
  1. Change permission with chmod 600 ~/.secrets/certbot/cloudflare.ini

  2. Then install using this

sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /home/yourUSER/.secrets/certbot/cloudflare.ini   -d 'ipang.my.id'

#for multiple domain
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /home/yourUSER/.secrets/certbot/cloudflare.ini   -d 'ipang.my.id' -d 'sub.ipang.my.id'
Certbot Install Success

Certbot Install Success


References:

certbot-dns-cloudflare’s documentation!