Setting up the StackPath CDN to use a Google Cloud Storage (GCS) bucket as an origin is a simple process that may require setting up storage.objects.list permissions for the StackPath CDN. This article will walk you through the setup process.
This article assumes you have already created a StackPath account, and have already performed the basic setup for a Google Cloud Storage Bucket.
Setting Up Bucket Access
For this example, the bucket was set up with Public Read access that allows everyone to view the bucket contents. This can be done by configuring bucket specific permissions and adding a rule, specifying all users the ability to read objects.
- Select the bucket settings drop-down and select edit bucket permissions
-
Typ
allUsers
into the "Add members" field, and choose Storage Object Viewer from the Select Role drop-down - Select Add and then the bucket will have global read-only permissions
To learn more about Google Cloud Storage permissions, browse here to configure your bucket differently, and allow only specific access.
Setting Up The CDN
In this tutorial, a bucket named "stackpathtesting" was used for integration. Replace any instance of "stackpathtesting" or <bucketname> with the actual name of the bucket you would like to integrate.
-
Log in to the StackPath Control Panel
- Create a new Site
- Create the Domain Name you would like to use, this can be any fully qualified domain name. For this example, the bucket address was used.
- Specify your bucket URL. Select "Origin Authentication" value, or leave at the default "None" if no authentication is required.
4.2 Go into the Settings tab for the newly created Site and confirm that the Host Header is<bucketname>.storage.googleapis.com
. You can check the full host header by clicking on the dropdown menu, or add this as a custom option, if necessary. -
Test the Site's Edge Address by navigating via the browser. This should produce an XML file that indexes the content of your GCS Bucket, showing that the CDN has access. The Edge Address can now be used to view any objects inside the bucket by going to
http://cdnurl/path/to/object
(Replacingcdnurl
with the actual Edge Address that was provided upon creating the Site.)
Next Steps
Connecting the StackPath CDN to your GCS Bucket can be useful for
- Hosting a Static Website with GCS with a Full Site Integration
- Using a GCS Bucket to host Static Assets on a Dynamic Website and using the CDN in its place