A 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 Source Type dropdown. Screenshot-Cloudflare-R2-source setup

  3. Fill in the details for the Cloudflare R2 Source (see the security notice below about access/secret keys). The parameters are:

    • Access Key ID: The Cloudflare R2 access key of the credentials you want imgix to connect with.
    • Secret Access Key: The Cloudflare R2 secret key of the credentials you want imgix to connect with.
    • Bucket: 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.
    • Prefix: The folder prefix you want to resolve to. The prefix is prepended to the asset path before resolving the asset in Cloudflare R2. By default the asset path is /.
  4. Name the Subdomain you'd like to use as the base URL for your assets.

    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.

  5. Set your Asset Processing Rules for the Asset Manager. This setting does not affect which assets can be served through the Rendering API. Instead, it will only impact which assets appear in the Asset Manager based on the path prefix configuration. You can choose to either:

    • Include all paths (default setting)
    • Include one or many user defined paths
    • Exclude all paths
    • Exclude one or many user defined paths
  6. Click the Save button. Your Source will be queued for deployment. Screenshot-Cloudflare R2 source setup


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.


Configuring CORS for uploading

To allow uploading assets directly into your Cloudflare R2 Object Storage using the imgix Asset Manager, you must allow the PUT method and the Content-Type header from https://dashboard.imgix.com in your R2 Object Storage's CORS configuration.

Refer to the Cloudflare R2 documentation for instructions on how to configure CORS. Here is a screenshot example of how your configuration should look like.

Screenshot - Adding CORS to Cloudflare R2 Object Storage

Advanced Settings

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

Next: Serving Assets