Fastly's CDN platform allows users to distribute their content among the Fastly edge cloud service. You can easily configure your buckets on Storj as a source of content and integrate them with Fastly.
Before you can connect your buckets to Fastly, you will first need a Fastly account. Once that is set up, follow the instructions below to configure a Fastly service with your buckets as an origin host.
To make your buckets available through the Fastly edge cloud network, you will configure Storj as your Fastly service's origin server.
To do that, you must first create a Fastly service using the following values as you go:
For the new Fastly domain and host, set the Domain Name field to the hostname you will be using for your URL. For example,
When you get to the Hosts section on the Origins page, enter the address of the Storj gateway endpoint (Storj-hosted S3 Compatible Gateway) you would like to use for this service. Include the name of your bucket, for example:
After adding the host, click the pencil icon to Edit this host and check that the following are correctly filled out:
Name: Any name you would like to use for your Fastly service
Address: This should be the address of your gateway endpoint
Additionally, if you have enabled TLS for your gateway and wish to configure that, check the following fields as well:
Enable TLS: The default for this is Yes
SNI hostname: Select Match the SNI hostname to the Certificate hostname. The gateway address you filled out and double-checked above should automatically appear.
Certificate hostname: This should be the same IP address or hostname of your gateway.
Note that if you are going to use AWS S3 integration, you may want to leave the Override host field blank when creating your service. Otherwise, it will override important authentication headers read by AWS (more on that below).
Fastly creates a DNS mapping from the domain you entered when creating your service to
<domain>.global.prod.fastly.net. So following the above steps, this would be
Create an alias in your own DNS settings for the domain name you are using. For example, create a CNAME record mapping
Fastly caches all content by default for 1 hour. This can be modified by sending a
Cache-Control header. If you are unsure whether you are sending any cache control headers, you can verify with a simple cURL command:
Since there are no
Cache-Control headers in this example, the default cache of 1 hour will be applied.
Fastly also has documentation on how different objects are cached. You can find more information in their cache freshness docs.
To integrate your S3 compatible gateway as an origin with Fastly, first create S3 credentials. You will need the Access key and Secret key, as well as your bucket name and gateway endpoint.
Next create a Fastly VCL snippet. Select the following options for your snippet:
Type: select within subroutine
In the dropdown box, select miss. Then, paste the following code into the VCL box. Update the variables where noted to the values from your access grant, bucket name, and bucket gateway:
Note that, as mentioned above, if you have an override host specified in your Fastly service settings, that value will cause the
http.host header to be overwritten which could be invalid for AWS authentication.
See also Storj DCS Object Storage on Fastly.