LetsEncrypt with Cloudflare

  • Views Views: 185
  • Last updated Last updated:
  • LetsEncrypt Certificates while using Cloudflare

    This guide will help you generate a LetsEncrypt Certificate while having your website behind Cloudflare. These instructions are for CentOS/RHEL, feel free to give your suggestions/instructions for other OSes in the discussion section.​

    First, run these commands to install the dependencies and create the cloudflare.ini file:

    Bash:
    yum install python2-pip
    pip install certbot-dns-cloudflare
    mkdir /root/.cloudflare-dns
    touch /root/.cloudflare-dns/cloudflare.ini

    Then, use your favorite editor to edit the cloudflare.ini file. An example with vim would be:

    Bash:
    vim /root/.cloudflare-dns/cloudflare.ini

    Paste the following information into the file and save it:

    Code:
    dns_cloudflare_email = "[email protected]"
    dns_cloudflare_api_key = "Your Global API Key"
    Now, we ensure that the file has correct permissions:

    Bash:
    chmod 0700 /root/.cloudflare-dns
    chmod 0400 /root/.cloudflare-dns/cloudflare.ini

    Finally, generate a fancy SSL certificate for your website. In this example, we are generating a wildcard certificate for *.domain.tld and domain.tld, but you can use whatever you like.

    Bash:
    certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/.cloudflare-dns/cloudflare.ini -d *.domain.tld,domain.tld --preferred-challenges dns-01
  • Loading…