Wasabi Hot Cloud Storage

Wasabi Hot Cloud Storage public and private buckets can be used as origins with Fastly.

Using Wasabi as an origin

To make your Wasabi Hot Cloud Storage bucket available through Fastly, follow the steps below.

Creating a new service

Follow the instructions for creating a new service.

  1. When you create the new domain and the new backend host:
    • In the Domain Name field on the Create a domain page, enter the hostname you want to use as the URL (e.g., cdn.example.com).
    • In the Hosts field on the Origins page, enter the appropriate address for your Wasabi Hot Cloud Storage bucket's region. For the us-east-1 region, enter <BUCKET>.s3.wasabisys.com. For all other regions, enter <BUCKET>.s3.<REGION>.wasabisys.com, replacing <REGION> as appropriate (e.g., <BUCKET>.s3.eu-central-1.wasabisys.com).
  2. When you edit the host details on the Edit this host page:
    • In the Name field, enter any descriptive name for your service if you haven't already done so.
    • In the Address field, ensure you've entered the appropriate address for your Host (e.g., <BUCKET>.s3.wasabisys.com). You entered this information during Host creation.
  3. When you edit the Transport Layer Security (TLS) area information for your host:
    • Leave the Enable TLS? default set to Yes to secure the connection between Fastly and your origin.
    • In the Certificate hostname field, enter the same address that appears in the Address field (e.g., <BUCKET>.s3.wasabisys.com).
    • Under the SNI hostname field, select the checkbox to Match the SNI hostname to the Certificate hostname. The address you entered during Host creation appears.
  4. In the Override host field, enter an appropriate address for your Host (e.g., <BUCKET>.s3.wasabisys.com). You entered this information during Host creation.
  5. From the Shielding menu below the TLS area, select an appropriate shielding location. For more information about this setting and which locations to select, see our enabling shielding information.

Enabling shielding

We strongly encourage you to enable shielding for your origin server. Wasabi imposes soft caps on free egress. Without shielding enabled, Fastly will request the same objects from all Fastly edge POPs instead of just one, which may not follow Wasabi's free egress guidelines.

When you select a shielding location from the Shielding menu, choose the location appropriate for your Wasabi Hot Cloud Storage bucket as follows:

Wasabi bucket regionShielding location
eu-central-1Amsterdam, NL
us-east-1Ashburn, VA
us-west-1Seattle, WA

Read our guidance on choosing a shield location for more information.

Testing your results

By default, we create a DNS mapping called yourdomain.global.prod.fastly.net. In the example above, it would be cdn.example.com.global.prod.fastly.net. Create a DNS alias for the domain name you specified (e.g., CNAME cdn.example.com to global-nossl.fastly.net).

Fastly will cache any content without an explicit Cache-Control header for 1 hour. You can verify whether you are sending any cache headers using curl. For example:

$ curl -I opscode-full-stack.s3.wasabisys.com
HTTP/1.1 200 OK
x-amz-id-2: ZpzRp7IWc6MJ8NtDEFGH12QBdk2CM1+RzVOngQbhMp2f2ZyalkFsZd4qPaLMkSlh
x-amz-request-id: ABV5032583242618
Date: Fri, 18 Mar 2012 17:15:38 GMT
Content-Type: application/xml
Transfer-Encoding: chunked

In this example, no Cache-Control headers are set so the default TTL will be applied.

Enhancing cache control

If you need more control over how different types of assets are cached (e.g., JavaScript files, images), check out our documentation on cache freshness.

Using private Wasabi Hot Cloud Storage buckets

To use a Wasabi Hot Cloud Storage private bucket with Fastly, you must implement version 4 of Amazon’s header-based authentication. You can do this using custom VCL and following the instructions below.

Before you begin

Make your Wasabi Hot Cloud Storage bucket available to Fastly. Be sure you've set your origin to port 443. This needs to be done before implementing header-based authentication with the instructions below.

Gathering Wasabi information

Start by obtaining the following information from Wasabi:

ItemDescription
Bucket NameThe unique name of your Wasabi Hot Cloud Storage bucket. When you download items from your bucket, this is the string listed in the URL path or hostname of each object (e.g., widget-project).
RegionThe Wasabi region code of the location where your bucket resides (e.g., us-east-1).
Access Key IDThe Wasabi access key ID string for an IAM account that has at least read permission on the bucket.
Secret Access KeyThe Wasabi secret access key paired with the access key above.

You should review the user access separation document to make sure you are not inadvertently exposing files you didn't intend e.g. allowing ListBucket operations etc. Alternatively you can use the VCL snippet from the bottom of the document to block bucket listing.

Once you have this information, you can configure your Fastly service to authenticate against your Wasabi bucket using header authentication by calculating the appropriate header value in VCL.

Creating a VCL snippet for authentication

Create a regular VCL snippet.

  • In the Name field, enter Wasabi protected origin.
  • In the Type (placement of the snippet) field, select within subroutine then choose miss (vcl_miss).
  • In the VCL field, place the following code (be sure to change specific values as noted to ones relevant to your own Wasabi bucket):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
if ( req.request == "GET" && req.backend.is_origin) {
declare local var.wasabiAccessKey STRING;
declare local var.wasabiSecretKey STRING;
declare local var.wasabiBucket STRING;
declare local var.wasabiRegion STRING;
declare local var.canonicalHeaders STRING;
declare local var.signedHeaders STRING;
declare local var.canonicalRequest STRING;
declare local var.canonicalQuery STRING;
declare local var.stringToSign STRING;
declare local var.dateStamp STRING;
declare local var.signature STRING;
declare local var.scope STRING;
# Supply your own credentials
set var.wasabiAccessKey = "YOUR_BUCKET_ACCESS_KEY"; # Change this value to your own data
set var.wasabiSecretKey = "YOUR_BUCKET_SECRET"; # Change this value to your own data
set var.wasabiBucket = "YOUR_BUCKET_NAME"; # Change this value to your own data
set var.wasabiRegion = "YOUR_BUCKET_REGION"; # Change this value to your own data
set bereq.http.x-amz-content-sha256 = digest.hash_sha256("");
set bereq.http.x-amz-date = strftime({"%Y%m%dT%H%M%SZ"}, now);
set bereq.http.host = var.wasabiBucket ".s3." var.wasabiRegion ".wasabisys.com";
set bereq.url = querystring.remove(bereq.url);
set var.dateStamp = strftime({"%Y%m%d"}, now);
set var.canonicalHeaders = ""
"host:" bereq.http.host LF
"x-amz-content-sha256:" bereq.http.x-amz-content-sha256 LF
"x-amz-date:" bereq.http.x-amz-date LF
;
set var.canonicalQuery = "";
set var.signedHeaders = "host;x-amz-content-sha256;x-amz-date";
set var.canonicalRequest = ""
"GET" LF
bereq.url.path LF
var.canonicalQuery LF
var.canonicalHeaders LF
var.signedHeaders LF
digest.hash_sha256("")
;
set var.scope = var.dateStamp "/" var.wasabiRegion "/s3/aws4_request";
set var.stringToSign = ""
"AWS4-HMAC-SHA256" LF
bereq.http.x-amz-date LF
var.scope LF
regsub(digest.hash_sha256(var.canonicalRequest),"^0x", "")
;
set var.signature = digest.awsv4_hmac(
var.wasabiSecretKey,
var.dateStamp,
var.wasabiRegion,
"s3",
var.stringToSign
);
set bereq.http.Authorization = "AWS4-HMAC-SHA256 "
"Credential=" var.wasabiAccessKey "/" var.scope ", "
"SignedHeaders=" var.signedHeaders ", "
"Signature=" + regsub(var.signature,"^0x", "")
;
unset bereq.http.Accept;
unset bereq.http.Accept-Language;
unset bereq.http.User-Agent;
unset bereq.http.Fastly-Client-IP;
}

Creating a VCL snippet to remove added response headers

You may also remove the headers that Wasabi adds to the response. Do this by creating another VCL snippet.

  • In the Name field, enter Strip Wasabi response headers.
  • In the Type (placement of the snippet) field, select within subroutine then select deliver (vcl_deliver).
  • In the VCL field, place the following code:
1
2
3
4
5
if ( !req.http.Fastly-Debug ) {
unset resp.http.x-amz-id-2;
unset resp.http.x-amz-request-id;
unset resp.http.server;
}

Blocking directory listing

If you don't set up correct IAM privileges you may allow users to list contents of your bucket folders. If you want to disallow that on Fastly please create following snippet

  • In the Name field, enter Disallow bucket listing.
  • In the Type (placement of the snippet) field, select within subroutine then select recv (vcl_recv).
  • In the VCL field, place the following code:
1
2
3
if ( req.url.path ~ "/$" ) {
error 403;
}
NOTE

This article describes an integration with a service provided by a third party. Read our note on integrations for details.

Was this guide helpful?

Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.