Getting StartedSetupCreating SourcesCloudflare R2

Adding a Cloudflare R2 Source

Cloudflare R2 Source connects to an existing Cloudflare R2 Object Storage. imgix connects using the credentials you supply, so your Cloudflare R2 assets don’t have to be public.

Setting Up Your Cloudflare R2 Source

  1. Go to the Sources page in the imgix dashboard and click the New Source button.

  2. Select Cloudflare from the How do you store your media? radio options.

Screenshot-Cloudflare-R2-source setup

  1. Fill in the details for your Cloudflare R2 Source.

Screenshot-Cloudflare-R2-source setup

Note: We strongly recommend creating R2 access keys specifically for imgix to access your R2 Object Storage with. Keep in mind that imgix only requires Admin Read and List permissions to begin serving your assets. For more information on how to generate your Access and Secret Access Keys or where to find other bucket details see the Cloudflare R2 Guide documentation.

  • Access Key ID: The Cloudflare R2 access key of the deployment credentials you want imgix to connect with.
  • Secret Access Key: The Cloudflare R2 secret key of the deployment credentials you want imgix to connect with.
  • Bucket Name: The name of the Cloudflare R2 Object Storage containing the assets you want imgix to connect to.
  • Endpoint URL: The S3 endpoint URL used by Cloudflare R2.
  • Region: The region of Cloudflare R2. The only acceptable value is auto.
  • Path Prefix (optional): The folder prefix you want to resolve to (if it exists). The prefix is prepended to the asset path before resolving the asset in Cloudflare R2. By default the asset path is /.
  1. Name the Subdomain you’d like to use as the base URL for your assets.

Screenshot-Cloudflare-R2-source setup

Note: The subdomain name you choose is unique to your Source and can’t be re-used. If you’re setting up a Source with a lot of customization (particularly a Custom Domain), choose the name you plan to use going forward.

  • If you are editing an existing Source and the Video API is enabled, the imgix Video Subdomain field will be visible. This field automatically inherits the value from your imgix Image Subdomain and cannot be modified without changing the Image Subdomain.
  1. Click the Save button on Step #3 to queue your Source for deployment.

Screenshot-Cloudflare R2 source setup

Cloudflare R2 Guide

We strongly recommend creating R2 access keys specifically for imgix to access your R2 Object Storage with. All Cloudflare R2 credentials are stored using industry standard cryptographic best practices.

Advanced Settings

See the Advanced Source Settings for information about setting up custom domains, defaults, and cache TTL options.

Uploading

To upload images and videos directly to your cloud-storage-backed Cloudflare R2 Source, you will have to create a separate set of upload_credentials. To upload to your Source directly through Asset Manager, you will also have to update your bucket’s CORS configuration. Uploading should only be implemented post-Source-deployment.

imgix’s rendering service does not need Write permissions to fetch assets; therefore, we highly recommend that you do not use the same credentials for your upload_credentials and your deployment_credentials.