Video bandwidth is usually the biggest bill. Cloudflare R2 is object storage with no charge for data sent to your viewers, which makes it a good home for HLS segments. Short version of the setup:
COSTS (Cloudflare pricing page, checked December 1, 2026. Prices can change.)
- Storage: $0.015 per GB-month (first 10 GB free)
- Class A operations (uploads, listing): $4.50 per million (first 1 million free)
- Class B operations (reads): $0.36 per million (first 10 million free)
- Egress: free
500 GB of video is about $7.35 per month. In HLS every segment a viewer downloads is one read, so a 1 hour film with 6 second segments is about 600 reads per full view.
STEP 1: Create a bucket in the dashboard (R2 Object Storage), keep it private.
STEP 2: Create an API token with Object Read & Write, limited to that bucket. Save the Access Key ID and Secret Key, they are shown once.
STEP 3: Install rclone with the official script (the apt version is too old) and add this to ~/.config/rclone/rclone.conf
[r2]
type = s3
provider = Cloudflare
access_key_id = YOUR_ACCESS_KEY_ID
secret_access_key = YOUR_SECRET_ACCESS_KEY
endpoint = https://YOUR_ACCOUNT_ID.r2.cloudflarestorage.com
acl = private
no_check_bucket = true
STEP 4: Upload your HLS folder
rclone copy ./movie1 r2:my-videos/movie1 --transfers 8 --progress
STEP 5: In the bucket Settings connect a custom domain (it must use Cloudflare DNS). Do not use the free r2.dev address in production, it is rate limited. Add a CORS policy that allows only your site as origin.
STEP 6: Add a Cache Rule for the video hostname with a long edge TTL. Cached files do not count as R2 reads.
STEP 7: Basic hotlink protection, WAF custom rule with action Block:
(http.host eq "video.example.com" and http.referer ne "" and not http.referer contains "example.com")
A Referer can be faked, so this only stops casual embedding.
Full guide with the CORS policy, troubleshooting and a test with curl:
Questions are welcome below.
COSTS (Cloudflare pricing page, checked December 1, 2026. Prices can change.)
- Storage: $0.015 per GB-month (first 10 GB free)
- Class A operations (uploads, listing): $4.50 per million (first 1 million free)
- Class B operations (reads): $0.36 per million (first 10 million free)
- Egress: free
500 GB of video is about $7.35 per month. In HLS every segment a viewer downloads is one read, so a 1 hour film with 6 second segments is about 600 reads per full view.
STEP 1: Create a bucket in the dashboard (R2 Object Storage), keep it private.
STEP 2: Create an API token with Object Read & Write, limited to that bucket. Save the Access Key ID and Secret Key, they are shown once.
STEP 3: Install rclone with the official script (the apt version is too old) and add this to ~/.config/rclone/rclone.conf
[r2]
type = s3
provider = Cloudflare
access_key_id = YOUR_ACCESS_KEY_ID
secret_access_key = YOUR_SECRET_ACCESS_KEY
endpoint = https://YOUR_ACCOUNT_ID.r2.cloudflarestorage.com
acl = private
no_check_bucket = true
STEP 4: Upload your HLS folder
rclone copy ./movie1 r2:my-videos/movie1 --transfers 8 --progress
STEP 5: In the bucket Settings connect a custom domain (it must use Cloudflare DNS). Do not use the free r2.dev address in production, it is rate limited. Add a CORS policy that allows only your site as origin.
STEP 6: Add a Cache Rule for the video hostname with a long edge TTL. Cached files do not count as R2 reads.
STEP 7: Basic hotlink protection, WAF custom rule with action Block:
(http.host eq "video.example.com" and http.referer ne "" and not http.referer contains "example.com")
A Referer can be faked, so this only stops casual embedding.
Full guide with the CORS policy, troubleshooting and a test with curl:
Questions are welcome below.