How to use Fastly CDN with B2 How to use Fastly CDN with B2

How to use Fastly CDN with B2

Udara Gunawardena Udara Gunawardena

Introduction

The Fastly Content Delivery Network allows you to cache your data using multiple servers across the world, dramatically reducing the amount of latency involved with accessing it. In this article, we will be going over the steps involved with setting up Fastly CDN as a front end for your public B2 bucket. 

 

Guide

Creating your B2 bucket 

  1. Create a public bucket on your Backblaze account. In this case, we are naming the bucket myb2content

    Screenshot_2023-02-15_at_12.31.23_PM.png

  2. In this particular demo, I have uploaded a jpeg resource named iris-8.jpeg into my newly created bucket. Take note of the S3 URL field. 

    Screenshot_2023-02-15_at_12.32.55_PM.png

 

Configuring your Fastly service

  1. If you already have a domain name configured, type in the domain name.  If not, you can configure your own that will at least temporarily (until the domain is registered) be addressable at the following address.

    <domain>.global.prod.fastly.net

    In this demo, I will be naming my website www.b2fastlycdn.com

    Screenshot_2023-02-15_at_3.30.17_PM.png
  2. Under Origins -> Hosts, create a new host with the hostname you gathered earlier from your bucket.

    In this scenario using the S3 URL, our hostname will be the URL past the bucket name.
    s3.us-west-000.backblazeb2.com

    Screenshot_2023-02-15_at_3.31.41_PM.png

  3. Press the pencil icon next to the hostname to edit the parameters of the host. Here we make sure Certificate Hostname, and SNI Hostname is the same as our base address.

    Screenshot_2023-02-15_at_3.31.09_PM.png


    Then we set the Override Host to the full S3 URL we gathered above including specifically the bucket name. 
    myb2content.s3.us-west-000.backblazeb2.com

    Screenshot_2023-02-15_at_3.31.16_PM.png
  4. Update the host and now you should be able to activate the service. You should now be able to navigate to any object stored in your b2 bucket by appending its path to your domain name.

    For example, navigating to b2fastlycdn.com.global.prod.fastly.net/iris-8.jpeg will display the jpeg picture of a car. 

    Screenshot_2023-02-15_at_2.59.40_PM.png

 

 

For more details on different approaches to setting up your Fastly CDN including instructions on how to set it up against a private bucket please visit their documentation