Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Monitor data and usage
Protection, backup, and recovery
Mount buckets with Cloud Storage FUSE
Work across products, Clouds, and platforms
Troubleshoot
Stay organized with collections Save and categorize content based on your preferences.
This page describes how to configure a Cloud Storage bucket to host a static website for a domain you own. Static web pages can contain client-side technologies such as HTML, CSS, and JavaScript. They cannot contain dynamic content such as server-side scripts like PHP.
OverviewBecause Cloud Storage doesn't support custom domains with HTTPS on its own, this tutorial uses Cloud Storage with an external Application Load Balancer to serve content from a custom domain over HTTPS. For more ways to serve content from a custom domain over HTTPS, see troubleshooting for HTTPS serving. You can also use Cloud Storage to serve custom domain content over HTTP, which doesn't require a load balancer.
For examples and tips on static web pages, including how to host static assets for a dynamic website, see the Static Website page.
Caution: This tutorial makes content available to the public internet. We recommend that you don't serve content that contains sensitive or private data from your Cloud Storage bucket.The instructions in this page describe how to perform the following steps:
Upload and share your site's files.
Set up a load balancer and SSL certificate.
Connect your load balancer to your bucket.
Point your domain to your load balancer using an A
record.
Test the website.
The instructions in this page use the following billable components of Google Cloud:
See the Monitoring your charges tip for details on what charges may be incurred when hosting a static website.
LimitationsYou can host a static website using a bucket whose objects are readable to the public. You cannot host a static website using a bucket that has public access prevention enabled. To host a static website using Cloud Storage, you can use either of the following methods:
Create a new bucket whose data can be accessed publicly. During bucket creation, clear the box labeled Enforce public access prevention on this bucket. After creating the bucket, grant the Storage Object Viewer role to the allUsers
principal. For more information, see Create a bucket.
Make the data of an existing bucket public. For more information, see Share your files.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
This tutorial uses the domain example.com
.
index.html
) and a 404 page (404.html
).example.com
, and not a subdomain, such as www.example.com
. If you purchased your domain through Cloud Domains, verification is automatic.Add the files you want your website to serve to the bucket:
ConsoleIn the list of buckets, click the name of the bucket that you created.
The Bucket details page opens with the Objects tab selected.
Click the Upload files button.
In the file dialog, browse to the desired file and select it.
After the upload completes, you should see the filename along with file information displayed in the bucket.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting.
Command lineUse the gcloud storage cp
command to copy files to your bucket. For example, to copy the file index.html
from its current location Desktop
to the bucket my-static-assets
:
gcloud storage cp Desktop/index.html gs://my-static-assets
If successful, the response looks like the following example:
Completed files 1/1 | 164.3kiB/164.3kiBClient libraries C++
For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample uploads an individual object:
The following sample uploads multiple objects concurrently:
The following sample uploads all objects with a common prefix concurrently:
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample uploads an individual object:
The following sample uploads multiple objects concurrently:
The following sample uploads all objects with a common prefix concurrently:
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample uploads an individual object:
The following sample uploads multiple objects concurrently:
The following sample uploads all objects with a common prefix concurrently:
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Terraform REST APIs Share your filesTo make all objects in your bucket readable to anyone on the public internet:
Caution: Before making your bucket publicly accessible, make sure that the files in your bucket don't contain sensitive or private information. ConsoleIn the list of buckets, click the name of the bucket that you want to make public.
Select the Permissions tab near the top of the page.
If the Public access pane reads Not public, click the button labeled Remove public access prevention and click Confirm in the dialog that appears.
Click the add_box Grant access button.
The Add principals dialog appears.
In the New principals field, enter allUsers
.
In the Select a role drop-down, select the Cloud Storage sub-menu, and click the Storage Object Viewer option.
Click Save.
Click Allow public access.
Once shared publicly, a link icon appears for each object in the public access column. You can click this icon to get the URL for the object.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting.
Command lineUse the buckets add-iam-policy-binding
command:
gcloud storage buckets add-iam-policy-binding gs://my-static-assets --member=allUsers --role=roles/storage.objectViewerClient libraries C++
For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Terraform REST APIs Note:roles/storage.objectViewer
includes permission to list the objects in the bucket. If you don't want to grant listing publicly, use roles/storage.legacyObjectReader
.
If wanted, you can alternatively make portions of your bucket publicly accessible.
Visitors receive a http 403
response code when requesting the URL for a non-public or non-existent file. See the next section for information on how to add an error page that uses a http 404
response code.
You can assign an index page suffix and a custom error page, which are known as specialty pages. Assigning either is optional, but if you don't assign an index page suffix and upload the corresponding index page, users who access your top-level site are served an XML document tree containing a list of the public objects in your bucket.
For more information on the behavior of specialty pages, see Specialty pages.
ConsoleIn the list of buckets, find the bucket you created.
Click the Bucket overflow menu (more_vert) associated with the bucket and select Edit website configuration.
In the website configuration dialog, specify the main page and error page.
Click Save.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting.
Command lineUse the buckets update
command with the --web-main-page-suffix
and --web-error-page
flags.
In the following sample, the MainPageSuffix
is set to index.html
and NotFoundPage
is set to 404.html
:
gcloud storage buckets update gs://my-static-assets --web-main-page-suffix=index.html --web-error-page=404.html
If successful, the command returns:
Updating gs://www.example.com/... Completed 1Note: Change or remove these settings with additional
buckets update
commands and view these settings with the buckets describe
command. Client libraries C++
For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
REST APIs Set up your load balancer and SSL certificateCloud Storage doesn't support custom domains with HTTPS on its own, so you also need to set up an SSL certificate attached to an HTTPS load balancer to serve your website through HTTPS. This section shows you how to add your bucket to a load balancer's backend and how to add a new Google-managed SSL certificate to the load balancer's frontend.
Select the load balancer typeIn the Google Cloud console, go to the Load balancing page.
The configuration window for your load balancer appears.
Basic configurationBefore continuing with the configuration, enter a Load balancer name, such as example-lb
.
This section shows you how to configure the HTTPS protocol and create an SSL certificate. You can also select an existing certificate or upload a self-managed SSL certificate.
For the IP address field:
example-ip
for the Name of the IP address.For Port, select 443.
In the Certificate field dropdown, select Create a new certificate. The certificate creation form appears in a panel. Configure the following:
example-ssl
.www.example.com
. If you want to serve your content through additional domains such as the root domain example.com
, press Enter to add them on additional lines. Each certificate has a limit of 100 domains.Click Create.
(Optional) If you want Google Cloud to automatically set up a partial HTTP load balancer for redirecting HTTP traffic, select the checkbox next to Enable HTTP to HTTPS redirect.
Click Done.
example-bucket
. The name you choose can be different from the name of the bucket you created earlier.my-static-assets
bucket you created earlier, and click Select.Routing rules are the components of an external Application Load Balancer's URL map. For this tutorial, you should skip this portion of the load balancer configuration, because it is automatically set to use the backend you just configured.
Review the configurationYou may need to wait a few minutes for the load balancer to be created.
Connect your domain to your load balancerAfter the load balancer is created, click the name of your load balancer: example-lb
. Note the IP address associated with the load balancer: for example, 30.90.80.100
. To point your domain to your load balancer, create an A
record using your domain registration service. If you added multiple domains to your SSL certificate, you must add an A
record for each one, all pointing to the load balancer's IP address. For example, to create A
records for www.example.com
and example.com
:
NAME TYPE DATA www A 30.90.80.100 @ A 30.90.80.100
See Troubleshooting domain status for more information about connecting your domain to your load balancer.
Recommended: Monitor the SSL certificate statusIt might take up to 60-90 minutes for Google Cloud to provision the certificate and make the site available through the load balancer. To monitor the status of your certificate:
Consoleexample-lb
.example-ssl
.To check the certificate status, run the following command:
gcloud compute ssl-certificates describe CERTIFICATE_NAME \ --global \ --format="get(name,managed.status)"
To check the domain status, run the following command:
gcloud compute ssl-certificates describe CERTIFICATE_NAME \ --global \ --format="get(managed.domainStatus)"
See Troubleshooting SSL certificates for more information about certificate status.
Test the websiteOnce the SSL certificate is active, verify that content is served from the bucket by going to https://www.example.com/test.html
, where test.html
is an object stored in the bucket that you're using as the backend. If you set the MainPageSuffix
property, https://www.example.com
goes to index.html
.
After you finish the tutorial, you can clean up the resources that you created so that they stop using quota and incurring charges. The following sections describe how to delete or turn off these resources.
Delete the projectThe easiest way to eliminate billing is to delete the project that you created for the tutorial.
To delete the project:
appspot.com
URL, delete selected resources inside the project instead of deleting the whole project.If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects can help you avoid exceeding project quota limits.
If you don't want to delete the entire project, delete the load balancer and bucket that you created for the tutorial:
example-lb
.my-static-assets
bucket or the example-ssl
SSL certificate.To delete the reserved IP address you used for the tutorial:
In the Google Cloud console, go to the External IP addresses page.
Select the checkboxes next to example-ip
.
Click Release static address.
In the confirmation window, click Delete.
If you're new to Google Cloud, create an account to evaluate how Cloud Storage performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
Try Cloud Storage freeExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4