this post was submitted on 17 Aug 2024
1 points (100.0% liked)

It's A Digital Disease!

23 readers
1 users here now

This is a sub that aims at bringing data hoarders together to share their passion with like minded people.

founded 2 years ago
MODERATORS
 
The original post: /r/datahoarder by /u/rojo_salas on 2024-08-17 06:52:05.

Hey Guys!

If you’re using Backblaze B2 for your storage needs and want to make your URLs look more professional or customized, you can easily set up a custom subdomain to serve multiple B2 buckets. Here's a step-by-step guide on how to do this using Cloudflare.

Note: This is only based on my working knowledge and research. There may be another or better way to do this but this is my take for this. I may have said/done something wrong, feel free to correct me so I can correct this post.)

Materials Used:

Step 1: Set Up Your CNAME Record

  1. Log in to Cloudflare:
    • Go to Cloudflare Dashboard and select your domain.
  2. Navigate to DNS Settings:
    • Click on the DNS tab.
  3. Add a CNAME Record: This CNAME setup directs requests from b2.rojosalas.com to your Backblaze B2 bucket endpoint.
    • Type: CNAME
    • Name: b2
    • Target: f002.backblazeb2.com
    • Proxy Status: Proxied (Cloudflare will handle the requests and apply your rules).

CNAME Record

Step 2: Create a Cloudflare Transform Rule

  1. Navigate to Transform Rules:
    • Go to Rules > Transform Rules in the Cloudflare dashboard.
  2. Create a New Transform Rule:
    • Click Create Transform Rule.
  3. Configure the Rule: This rule will ensure that requests to b2.rojosalas.com will be properly mapped to the Backblaze B2 URL with the /file prefix.
    • Name: Provide a name for your rule (e.g., "Rewrite Backblaze B2 Paths").
    • When incoming requests match:
      • Expression(http.host eq "b2.rojosalas.com") or (http.host eq "https://b2.rojosalas.com")
      • Path Matching: No separate field, include in the rule directly.
    • Rewrite URL:
      • Rewrite toDynamic
      • Valueconcat("/file", http.request.uri.path)

Transform Rule

Example Usage

With the transform rule set up, you can now use your subdomain to access multiple buckets through the subdirectory. Here’s how it works:

With this setup, you can easily reference and serve files from multiple Backblaze B2 buckets under one custom subdomain.

Note: This is only based on my working knowledge and research. There may be another or better way to do this but this is my take for this. I may have said/done something wrong, feel free to correct me so I can correct this post.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here