Overview
You can use this document to learn how to set a Google Cloud storage bucket as the origin for a CDN site.
At a high level, you must:
- Update your bucket's permission
- Create or update a CDN site
Step 1: Update your bucket's permissions
To allow the StackPath CDN to access your bucket, you must update your bucket's access permissions and add a rule.
- In the Google Cloud Console, open the Cloud Storage browser.
- Select the bucket settings drop-down menu, and then select Edit bucket permissions.
- Under Add members, enter allUsers.
- In the drop-down menu, select Storage Object Viewer, and then click Add.
- The bucket now has global read-only permissions.
- The bucket now has global read-only permissions.
- To learn more about bucket permissions, including how to configure the bucket and only allow select access, visit the Google Cloud documentation site.
Step 2: Add a bucket as the site origin
You can:
- Create a CDN site and add a Google Cloud storage bucket as the origin
- Update an existing CDN site to add a Google Cloud storage bucket as the origin
Option 1: Create a CDN site
- In the StackPath Control Portal, in the left-side navigation, click Sites.
- Click Create Site.
- In Domain Name, enter a domain name. You can enter a fully qualified domain name or the name of the bucket.
- For example, for a bucket named stackpathtesting, you would enter stackpathtesting.storage.googleapis.com. Enter a domain with your actual bucket name.
- Mark CDN, and then click Continue.
- Under Hostname/IP Address, enter the bucket URL.
- For example, for a bucket named stackpathtesting, you would enter stackpathtesting.storage.googleapis.com. Enter a domain with your actual bucket name.
- (Optional) Under Origin Authentication, select an authentication type to connect to your origin.
-
Select Basic to input a username and password that will be passed through basic HTTP authentication, if required by your origin server.
- Select None not to pass an authentication to the origin server.
-
- Click Continue.
- You will be redirected to the Overview screen for the newly created site.
- In the left-side navigation, click Settings.
- Review the Host Header to confirm that the bucket URL is selected and displayed.
- In the top, right corner of the screen, copy the Site's Edge Address, and then paste the address into a web browser.
- When you press Enter in the web browser, you should see an XML file that contains an index of all the objects within that bucket, which indicates that the CDN has access to your bucket.
- When you press Enter in the web browser, you should see an XML file that contains an index of all the objects within that bucket, which indicates that the CDN has access to your bucket.
- You can now serve your bucket objects over the CDN cache with http://cdn.url/path/to/bucket/object.
- Replace cdn.url with the edge address you copied earlier.
Option 2: Update an existing site
- In the StackPath Control, in the left-side navigation, click Sites.
- Locate and select the desired site.
- In the left-side navigation, click Settings.
- In the field next to Address, enter the bucket URL.
- For example, for a bucket named stackpathtesting, you would enter stackpathtesting.storage.googleapis.com. Enter a domain with your actual bucket name.
- Click Save.
Next steps
After you create a CDN site with a Google Cloud storage bucket, you can:
- Use your bucket to host a static website.
- To learn more, visit the Google Cloud documentation site.
- Use your bucket to host a static assets on a dynamic website.
- To learn more, visit the Google Cloud documentation site.