How to protect video from R2

I have a website that sells videos. We’re looking for a storage solution. We like R2, but we haven’t found a way to secure the videos against downloading or sharing via video url. Is there a way to stream videos using a woker or something? Are there better options to protect mp4 from sharing the url directly to the file or downloading it?

Might Cloudlflare video be better for our case?

1 Like

I’ll just add that it is clear to me that there is no 100% protection against downloads. The point is to reduce it enough for most users.

I can’t find a solution for this either, I hope cloudflare can implement a solution that can prevent this, other websites are abusing my R2 bucket, they copy direct video link and embed on their websites and I can’t prevent that

1 Like

Having the same issue! I have tried everything from WAF settings to workers! the WAF block the link, but doesnt let the files on my site to download, just returns with a 0 size file :confused:

Welcome to the Cloudflare Community.

Two main options come to mind, both require access to a backend with custom code (this can be a Worker).

  1. Create a presigned URLs which is only valid for a certain time, and send this to the client: Presigned URLs · Cloudflare R2 docs
  2. If on a Pro or higher plan, you can do the same thing with HAMC in the WAF instead: Functions reference · Cloudflare Ruleset Engine docs - benefit of this is that you can still benefit from Cloudflare CDN features. Set this up with a public bucket, then add the WAF rule on top.

Alternatively while not a direct solution to the problem, Cloudflare Stream has an equivalent solution as well: Secure your Stream · Cloudflare Stream docs