home-assistant.io/source/_integrations/cloudflare.markdown
2020-02-12 19:59:10 +01:00

3.5 KiB

title, description, logo, ha_category, ha_release, ha_codeowners
title description logo ha_category ha_release ha_codeowners
Cloudflare Automatically update your Cloudflare DNS records. cloudflare.png
Network
0.74
@ludeeus

With the cloudflare integration, you can keep your Cloudflare records up to date.

The integration runs every hour, but can also be started manually by using the service cloudflare.update_records under services.

Setup

You can find your global API key in your Cloudflare account settings.

Configuration

To use the integration in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
cloudflare:
  email: YOUR_EMAIL_ADDRESS
  api_key: YOUR_GLOBAL_API_KEY
  zone: EXAMPLE.COM
  records:
    - ha
    - www

{% configuration cloudflare %} email: description: The email address for your Cloudflare account. required: true type: string api_key: description: The global API key for your Cloudflare account. required: true type: string zone: description: The DNS zone (domain) you want to update. required: true type: string records: description: A list of records (subdomains) you want to update. required: true type: list {% endconfiguration %}

Additional information

Usage of external service

This platform uses the API from ipify.org to set the public IP address.

API Key

Please note that the api_key is the global API key of your Cloudflare account (not the API Token).

Home Assistant Companion App

If you would like to use iOS App via Cloudflare set Minimum TLS version as 1.2, in order to do that, do the following:

  1. Login to your Cloudflare account.
  2. Choose your domain.
  3. Click on the SSL/TLS icon.
  4. Go to tab Edge Certificates.
  5. Find Minimum TLS Version and set it to 1.2.

Other settings should not cause any issues.

SSH over Cloudflare

For SSH usage (according to this source), you need to connect directly to your server (bypassing Cloudflare). To do that, create a CNAME DNS record, e.g., ssh.example.com, with proxy status as "DNS only" (to do that click on orange icon, it will change color to gray) and then connect to ssh.example.com using your server SSH port.

Using Cloudflare domain only for Home Assistant

If you want to update just a main domain, place in the records list only your domain, e.g., example.com. It will update your A DNS record with your IP every hour.

# Example configuration.yaml entry for one domain
cloudflare:
  email: YOUR_EMAIL_ADDRESS
  api_key: YOUR_GLOBAL_API_KEY
  zone: EXAMPLE.COM
  records:
    - EXAMPLE.COM

The minimum DNS record settings (if you have set up HTTPS already)

To redirect from your domain to the IP address of your Home Assistant server set this DNS record:

Type: A
Name: @
IPv4 Address: your.ip.address

You can find your current IP address using this page.

In order to redirect from https://www to https:// you need to set this DNS record:

Type: CNAME
Name: @
Target: example.com (your actual domain)

And also create Page Rule:

If the URL matches: www.example.com*
Then the settings are: Forwarding URL
Status: 302 - Temporary redirect
Destination URL: https://example.com/$1