Configuring Cloudflare DNS – Render Docs

This guide assumes you've already added a custom domain from Cloudflare to your service in the Render Dashboard. If you haven't done this yet, first read Custom Domains.

Common setup

Most commonly when setting up a Cloudflare custom domain, you add a CNAME record for the root domain, along with another for the www subdomain.

Remove all AAAA records for your domain if it has any. AAAA records map a domain to a corresponding IPv6 record, but Render does not yet support IPv6 addresses. As a result, AAAA records can interfere with your custom domain's behavior on Render.

  1. Log in to your Cloudflare dashboard and select your domain from the Home page to open its settings.

  2. Navigate to SSL/TLS > Overview. Set your encryption mode to Full:

  3. Navigate to DNS > Records and click Add record.

  4. Create a new CNAME record that points to your Render service's onrender.com subdomain (obtain this value in the Render Dashboard):

Click Save.

  1. Repeat the previous step to create a second CNAME record.

Click Save.

  1. Your completed configuration should resemble this:

That's it! DNS changes might take a few minutes to propagate, after which your domain points to your Render service. You can check the status of your service's certificates and manually request verification in the Render Dashboard under Custom Domains:

After the Render Dashboard indicates that your certificates are issued and valid, you can optionally set Proxy status to Proxied for your CNAME records.

Adding a wildcard custom domain without the base domain

Your Cloudflare domain requires some additional configuration if all of the following are true:

Origin override with a Cloudflare Worker

To direct wildcard traffic to Render while directing base domain traffic elsewhere, you can use a Cloudflare Worker to perform an origin override.

The instructions below assume the following:

1. Add a DNS record pointing to base-domain-origin.com

2. Create a Worker

  1. Navigate to Workers -> Overview -> Create Service

  2. Name your service base-domain-override, select HTTP Handler, and click Create service

  3. Scroll down and click Quick Edit.

  4. Add the following configuration. Replace example.com with your custom domain and make sure the base-domain-origin subdomain matches the DNS record you created in the first step.

addEventListener('fetch', (event) => {
     event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
     return fetch(request, {
       cf: { resolveOverride: 'base-domain-origin.example.com' },
     })
}
  1. Click Save and Deploy -> Navigate back to the Worker overview page -> Click Triggers -> Add Route

  2. Add a route matching your base domain and click Add Route:

  3. Finally, add CNAME records for both your base domain and wildcard domain pointing to your onrender subdomain. Pointing your base domain to Render is required for an orange to orange setup. With this configuration, Cloudflare will send traffic to your zone first. The Worker that you just set up will match the route and trigger an origin override, so traffic for the base domain will not get sent to Render. If you do not do this, Cloudflare will send the traffic directly to Render's zone and the Worker you set up will have no effect.

Your wildcard traffic should now be directed to Render and your base domain traffic directed to the origin you specified. If you have any questions, you can get in touch with us at support@render.com.